Kalmat / PyMonCtl

Cross-Platform module which provides a set of features to get info on and control monitors/screens/displays.
BSD 3-Clause "New" or "Revised" License
5 stars 3 forks source link

doesn't get the full list of monitors #3

Open leporel opened 1 year ago

leporel commented 1 year ago

pymonctl don't return all my monitors (one of them connected to nvidia card (display port, 144hz), other to motherboard integrated gpu (hdmi 60hz))

import pymonctl as pmc
from screeninfo import get_monitors

print(pmc.getAllMonitorsDict())
print("--------------")
for m in get_monitors():
    print(str(m))

return:

{'\\\\.\\DISPLAY5': {'system_name': '\\\\.\\DISPLAY5', 'id': 131073, 'is_primary': False, 'position': Point(x=1920, y=0), 'size': Size(width=1920, height=1080), 'workarea': Rect(left=1920, top=0, right=3840, bottom=1050), 'scale': (100, 100), 'dpi': (96, 96), 'orientation': 0, 'frequency': 60, 'colordepth': 32}}
--------------
Monitor(x=0, y=0, width=1920, height=1080, width_mm=527, height_mm=296, name='\\\\.\\DISPLAY1', is_primary=True)
Monitor(x=1920, y=0, width=1920, height=1080, width_mm=527, height_mm=296, name='\\\\.\\DISPLAY5', is_primary=False)
print(pmc.getAllMonitors())
print(pmc.getMonitorsCount())

> [<pymonctl._pymonctl_win.Win32Monitor object at 0x0000024798C0F760>, <pymonctl._pymonctl_win.Win32Monitor object at 0x0000024798C0F880>]
> 2
leporel commented 1 year ago

image

Monitor1 image and this if statement resulting false

Monitor2 image

win32con.DISPLAY_DEVICE_ATTACHED_TO_DESKTOP show as 1

leporel commented 1 year ago

actually i have 3 monitors, but one disabled in windows (Settings->Display->Disconnect this display), when activate him its seems all 3 display is showing

{'\\\\.\\DISPLAY1': {'system_name': '\\\\.\\DISPLAY1', 'id': 131130, 'is_primary': True, 'position': Point(x=0, y=0), 'size': Size(width=1920, height=1080), 'workarea': Rect(left=0, top=0, right=1920, bottom=1050), 'scale': (100, 100), 'dpi': (96, 96), 'orientation': 0, 'frequency': 144, 'colordepth': 32}, 
'\\\\.\\DISPLAY5': {'system_name': '\\\\.\\DISPLAY5', 'id': 131073, 'is_primary': False, 'position': Point(x=1920, y=0), 'size': Size(width=1920, height=1080), 'workarea': Rect(left=1920, top=0, right=3840, bottom=1050), 'scale': (100, 100), 'dpi': (96, 96), 'orientation': 0, 'frequency': 59, 'colordepth': 32},
 '\\\\.\\DISPLAY2': {'system_name': '\\\\.\\DISPLAY2', 'id': 1878003877, 'is_primary': False, 'position': Point(x=127, y=-1080), 'size': Size(width=2560, height=1080), 'workarea': Rect(left=127, top=-1080, right=2687, bottom=-30), 'scale': (100, 100), 'dpi': (96, 96), 'orientation': 0, 'frequency': 59, 'colordepth': 32}}

i supposing here is some bug when get dev.StateFlags for DISPLAY1

Kalmat commented 1 year ago

Hi! Sorry for my late reply. I've been out these days with no access to my "stuff". Thank you a LOT for your feedback!

Let me ask if I properly understood the issue. You start the script with one of your monitors de-activated (detached). Then, at one point, you activate it, but somehow dev.StateFlags doesn't return proper updated value... is this the case?

First off, PyMonCtl is not intended to return non-active or detached monitors... If you need it, we can think of a new function or an input parameter to getMonitors() to force to return ALL monitors despite they are active/online/attached or not.

Please, let me know what you think.

leporel commented 1 year ago

Let me ask if I properly understood the issue. You start the script with one of your monitors de-activated (detached). Then, at one point, you activate it, but somehow dev.StateFlags doesn't return proper updated value... is this the case?

I apologise for my English, I might have expressed my thoughts incorrectly. No, these my state when i start script:

Windows Script dev.StateFlags
DISPLAY1 Active processed but not returned 2
DISPLAY5 Active returned 3
DISPLAY2 de-activated empty? -

Note: win32api.EnumDisplayMonitors() returned 2 monitors: DISPLAY1 and DISPLAY5 (but in device manager i see 3 monitors, i.e. DISPLAY2 not detached, he just deactivated in windows displays settings)

when i activate DISPLAY2 in windows: Windows Script dev.StateFlags
DISPLAY1 Active returned 3
DISPLAY5 Active returned 3
DISPLAY2 Active returned 3

My problem, when DISPLAY2 de-activated, DISPLAY1 processed as non-active (DISPLAY1 is primary always)

something wrong with StateFlag, he think DISPLAY1 DISPLAY_DEVICE_ATTACHED_TO_DESKTOP is 0 in bitmask

Kalmat commented 1 year ago

Oh, ok. Understood!! Really weird behavior in deed... Let me dig into it and will come back to you with my findings. We will solve it!!!

Thanks a lot for your feedback and help!!!

Kalmat commented 1 year ago

Hi again!

Solution found and will be solved in next version!

Checking dev.StateFlag is not really required. It's a remnant from previous versions. Using win32api.EnumDisplayMonitors() and win32api.GetMonitorInfo() is enough to retrieve all required values. It is much simpler now as well.

Thank you for pointing it out!