I was messing around for fun with ImageGrab and I noticed that if you have set a custom zoom-factor in your OS, if you grab a full-screen image a portion of the capture will be black.

For example, in my laptop I have a resolution of 1920x1080 and I've set a 140% zoom in Win10. If I grab a fullscreen, here's the result:
enter image description here

on the other hand, when the OS zoom is defaulted t0 100%, this is the correct fullscreen: enter image description here

The code I use is very basic, I'll show it just for completeness:

from PIL import ImageGrab as ig
from pynput.mouse import Button, Controller
from pynput.keyboard import Key
from pynput import keyboard

def onpress(k):
    if k == keyboard.Key.esc:
        # break if esc is pressed
        return False
    else:
        img= ig.grab()
        img.save('screenshot.png')

with keyboard.Listener( on_press= onpress) as listener:
    listener.join()

I've noticed by logging the mouse position that when the screen is set at 140% zoom, the borders are at 0,0 - 1374,738 approximately.

1 Answers

0
davide m. On Best Solutions

Found the solution on a Github thread. It has to do with the DPI of my laptop's screen.