В качестве обходного пути вы можете использовать ctypes.windll
:
import ctypes
from ctypes.wintypes import tagPOINT
from ctypes import *
class RECT(Structure):
_fields_ = [
("left", c_long),
("top", c_long),
("right", c_long),
("bottom", c_long),
]
class MONITORINFOEXA(Structure):
_fields_ = [
("cbSize", c_ulong),
("rcMonitor", RECT),
("rcWork", RECT),
("dwFlags", c_ulong),
("szDevice", c_char*32),
]
class MONITORINFOEXW(Structure):
_fields_ = [
("cbSize", c_ulong),
("rcMonitor", RECT),
("rcWork", RECT),
("dwFlags", c_ulong),
("szDevice", c_wchar*32),
]
point = tagPOINT(0,0)
handle_for_primary_monitor = ctypes.windll.user32.MonitorFromPoint(point,0)
print(handle_for_primary_monitor)
monitorinfo = MONITORINFOEXW()
#monitorinfo.cbSize = 72 #sizeof(MONITORINFOEXA) = 72 ;sizeof(MONITORINFOEXW) = 104
monitorinfo.cbSize = 104
monitorinfo.dwFlags = 0x01 #MONITORINFOF_PRIMARY
#ctypes.windll.user32.GetMonitorInfoW(handle_for_primary_monitor,byref(monitorinfo))
ctypes.windll.user32.GetMonitorInfoW(handle_for_primary_monitor,byref(monitorinfo))
Monitor_width = monitorinfo.rcMonitor.right - monitorinfo.rcMonitor.left
Monitor_height = monitorinfo.rcMonitor.bottom - monitorinfo.rcMonitor.top
Work_width = monitorinfo.rcWork.right - monitorinfo.rcWork.left
Work_height = monitorinfo.rcWork.bottom - monitorinfo.rcWork.top
print(monitorinfo.szDevice)
print(Monitor_width)
print(Monitor_height)
print(Work_width)
print(Work_height)