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

白昼怎懂夜的黑 提交于 2019-12-25 16:47:48

问题


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

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

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?

thank you so much.


回答1:


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()

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..



来源:https://stackoverflow.com/questions/44774169/screenshot-pilimagegrab-grab-bitblt-on-win10-only-return-the-background

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!