python-mss icon indicating copy to clipboard operation
python-mss copied to clipboard

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

Open anonymousvic opened this issue 5 years ago • 7 comments

General information:

  • OS name: Windows 10

  • OS version: 20H2

  • OS architecture: 64 bits

  • Resolutions:

    • Monitor 1: 2560x1600(Scale is 175% and the resolution after it is 1463x914)
  • Python version: 3.8.5

  • MSS version: 6.1.0

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

anonymousvic avatar Dec 15 '20 14:12 anonymousvic

GetSystemMetrics is for Windows, not GNU/Linux.

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

BoboTiG avatar Dec 15 '20 14:12 BoboTiG

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

BoboTiG avatar Dec 15 '20 14:12 BoboTiG

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.

anonymousvic avatar Dec 15 '20 14:12 anonymousvic

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

BoboTiG avatar Dec 15 '20 17:12 BoboTiG

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

anonymousvic avatar Dec 16 '20 01:12 anonymousvic

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

narumi147 avatar Dec 17 '20 09:12 narumi147

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

BoboTiG avatar Dec 17 '20 09:12 BoboTiG