BoboTiG / python-mss

An ultra fast cross-platform multiple screenshots module in pure Python using ctypes.
https://pypi.org/project/mss/
MIT License
1.01k stars 93 forks source link

GetSystemMetrics module returns wrong screen resolution after running sct.grab(monitor) #197

Closed anonymousvic closed 1 year ago

anonymousvic commented 3 years ago

General information:

Description of the warning/error

Neither

Full message

Nope

Other details

First python code is below:

from win32.win32api import GetSystemMetrics
w = GetSystemMetrics (0)
h = GetSystemMetrics (1)

It can return the right resolution: 1463x914

Second python code is below:

from win32.win32api import GetSystemMetrics
import mss

left, top, right, bottom = (100,100,900,700)
with mss.mss() as sct:
    # Part of the screen to capture
   monitor = {'top': top, 'left': left, 'width': right-left, 'height': bottom-top}
   world_sct = np.array(sct.grab(monitor))

w = GetSystemMetrics (0)
h = GetSystemMetrics (1)

It returns: 2560x1600

GetSystemMetrics gives the wrong resolution after taking a screen shot by mss

BoboTiG commented 3 years ago

GetSystemMetrics is for Windows, not GNU/Linux.

Also, please fill the issue template, I cannot help without information.

BoboTiG commented 3 years ago

Also, the latest release is 6.1.0. 3.2.0 is quite old.

anonymousvic commented 3 years ago

Also, the latest release is 6.1.0. 3.2.0 is quite old.

Sorry, I pressed the "enter" with incaution when I was filling the template, and I'm filling it now.

BoboTiG commented 3 years ago

What is the resolution set on the monitor? 2560x1600 seems appropriate with 175% scale. 🤔

anonymousvic commented 3 years ago

What is the resolution set on the monitor? 2560x1600 seems appropriate with 175% scale. 🤔

My monitor size is 13 inches and the resolution is 2560x1600, so I set 175% scale to make everything bigger

narumi147 commented 3 years ago

mss instance will set High DPI awareness = PROCESS_PER_MONITOR_DPI_AWARE. So before using mss, the PROCESS is NOT DPI aware, you got 1463x914. Once mss instance created, the PROCESS is DPI aware, then you got the actual resolution 2560x1600.

What's more, during the full lifecycle of PROCESS, DPI awareness can be only set once programmatically or in manifest. Although Windows10 introduces Mixed-Mode DP-aware and support THREAD DPI awareness?

For more details: https://docs.microsoft.com/en-us/windows/win32/hidpi/setting-the-default-dpi-awareness-for-a-process

BoboTiG commented 3 years ago

Thanks @narumishi :) @anonymousvic this is not a bug indeed.