Skip to content

Importing pyautogui breaks monitor DPI detection with ctypes #663

Open
@GeorgeWashingtonABCDEFG

Description

import ctypes
# import pyautogui
dpix = ctypes.c_uint()
dpiy = ctypes.c_uint()
ctypes.windll.shcore.SetProcessDpiAwareness(2)
ctypes.windll.shcore.GetDpiForMonitor(1186359,0,ctypes.byref(dpix),ctypes.byref(dpiy))
print(dpix.value)

# output
144 # this is correct

import ctypes
import pyautogui
dpix = ctypes.c_uint()
dpiy = ctypes.c_uint()
ctypes.windll.shcore.SetProcessDpiAwareness(2)
ctypes.windll.shcore.GetDpiForMonitor(1186359,0,ctypes.byref(dpix),ctypes.byref(dpiy))
print(dpix.value)

# output
96 # this is wrong. The monitor's dpi is 144. Note the monitor is scaled in windows.
# Everything I do about detecting window size, location, etc is all broken by simply importing your module.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions