屏幕截图(PIL)ImageGrab.grab/Win10上的BitBlt仅返回背景吗? [英] Screenshot (PIL)ImageGrab.grab / BitBlt on Win10 only return the Background?

查看:403
本文介绍了屏幕截图(PIL)ImageGrab.grab/Win10上的BitBlt仅返回背景吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Windows 10上遇到了一个大问题,通常我使用PIL(Python)从程序内部获取漂亮干净的屏幕截图.

i have a big problem with windows 10, normaly i used PIL (Python) to get a nice and clean screenshot from inside a program.

但是对于Windows 10来说,它不再起作用了,现在我只能成为桌面上的所有内容,但是我的全屏窗口却不见了.

but with windows 10 this does not work anymore, now i become only everything on the Desktop but my FullScreen Window is missing.

我也尝试使用:

BitBlt(screen_copy, 0, 0, width, height, screen, left, top, SRCCOPY | CAPTUREBLT)

但结果完全相同:(

有人有什么解决方案或想法吗,Win10中发生了什么变化?

does anybody has any solution or idea what has changed in Win10?

非常感谢您.

推荐答案

另一种非常快速的方法是

Another approach that is really fast is the MSS module. It uses only the ctypes standard module, so it does not require any dependencies. It is OS independant, works with Windows 10 and its use is made easy:

from mss import mss

with mss() as sct:
    sct.shot()

,然后找到包含第一个监视器的屏幕截图的screenshot.png文件.有很多可能的自定义项,您可以使用ScreenShot对象和OpenCV/Numpy/PIL/etc ..

And just find the screenshot.png file containing the screen shot of the first monitor. There are a lot of possibile customizations, you can play with ScreenShot objects and OpenCV/Numpy/PIL/etc..

这篇关于屏幕截图(PIL)ImageGrab.grab/Win10上的BitBlt仅返回背景吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆