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 captures
As you can see, the screen has a good amount of space chopped off on the side and along the bottom. I tried to correct this by adjusting the size of the capture zone, but that just resulted in the extra areas just to be filled with black
I'm thinking that there is a limit to the maximum resolution that the library can capture, but I cant really find any documentation saying so.
Below is my code
import ImageGrab
import os
import time
def screenGrab():
box = (0, 0, 1920, 1080)
im = ImageGrab.grab(box)
im.save(os.getcwd() + '\\screenshot_' + str(int(time.time())) + '.png', 'PNG')
def main():
screenGrab()
if __name__ == '__main__':
main()
Dose anyone know how to fix this issue or know why its happening?
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
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.
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
This will result is a smaller but sharper text and icons.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With