Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doesn't get the full list of monitors #3

Open
leporel opened this issue Sep 29, 2023 · 6 comments
Open

doesn't get the full list of monitors #3

leporel opened this issue Sep 29, 2023 · 6 comments

Comments

@leporel
Copy link

leporel commented Sep 29, 2023

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

  • Windows 10 (Windows 11 same behavior's)
  • python 3.10.11
  • PyMonCtl 0.7
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
Copy link
Author

leporel commented Sep 29, 2023

image

Monitor1
image
and this if statement resulting false

Monitor2
image

win32con.DISPLAY_DEVICE_ATTACHED_TO_DESKTOP show as 1

@leporel
Copy link
Author

leporel commented Sep 29, 2023

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
Copy link
Owner

Kalmat commented Oct 4, 2023

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
Copy link
Author

leporel commented Oct 4, 2023

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
Copy link
Owner

Kalmat commented Oct 4, 2023

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
Copy link
Owner

Kalmat commented Oct 11, 2023

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants