Python Imaging Library fails to grab whole screen

前端 未结 2 620
甜味超标
甜味超标 2020-12-10 07:37

I am using PIL to grab a screen shot, but it is only capturing a part of the screen.

Here is a screen shot of my desktop

And this is what the program captur

相关标签:
2条回答
  • 2020-12-10 08:26

    I was having this problem too earlier today. The script would only capture pixels 0,0 - 1536,864. I recently switched to windows 8 and noticed that some programs seemed to be displayed at the incorrect resolution. After some searching I found a fix.

    • Go to your python directory (c:/python27/ for me)
    • Right click python.exe and select properties
    • Select the compatibility tab
    • Press the "Change settings for all users" button
    • Check the "Disable display scaling on high DPI settings" box
    • ImageGrab will now capture the entire resolution

    I'll update if I find a universal fix, but I thought I'd post here since I searched for an hour or so and couldn't find a solution.

    EDIT:

    Universal fix

    • right click desktop
    • select "screen resolution"
    • click on "make text and other items larger or smaller"
    • check "let me choose one scaling level for all my displays"
    • select "smaller - 100%"

    This will result is a smaller but sharper text and icons.

    0 讨论(0)
  • 2020-12-10 08:30

    There is a working workaround for this without fiddling with the OS settings. The solution is to use the following to make your program DPI aware on Windows :

    from ctypes import windll
    user32 = windll.user32
    user32.SetProcessDPIAware()
    

    Hope that helps

    0 讨论(0)
提交回复
热议问题