简体   繁体   English

屏幕截图(PIL)Win10上的ImageGrab.grab / BitBlt仅返回背景吗?

[英]Screenshot (PIL)ImageGrab.grab / BitBlt on Win10 only return the Background?

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上遇到了一个大问题,通常我使用PIL(Python)从程序内部获取漂亮干净的屏幕截图。

but with windows 10 this does not work anymore, now i become only everything on the Desktop but my FullScreen Window is missing. 但是对于Windows 10,它不再起作用了,现在我只能成为桌面上的所有内容,但是缺少全屏窗口。

i also tryed to use: 我也尝试使用:

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

but the result is exactly the same :( 但结果是完全一样的:(

does anybody has any solution or idea what has changed in Win10? 是否有人有解决方案或想法,Win10中发生了什么变化?

thank you so much. 非常感谢。

Another approach that is really fast is the MSS module. 另一个非常快的方法是MSS模块。 It uses only the ctypes standard module, so it does not require any dependencies. 它仅使用ctypes标准模块,因此不需要任何依赖关系。 It is OS independant, works with Windows 10 and its use is made easy: 它独立于操作系统,可与Windows 10一起使用,并且易于使用:

from mss import mss

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

And just find the screenshot.png file containing the screen shot of the first monitor. 只需找到包含第一个监视器的屏幕screenshot.png文件即可。 There are a lot of possibile customizations, you can play with ScreenShot objects and OpenCV/Numpy/PIL/etc.. 有许多可能的自定义项,您可以使用ScreenShot对象和OpenCV / Numpy / PIL /等。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM