sgrottel / tiny-tools-collection

Assortment of tiny, tiny tools
MIT License
4 stars 0 forks source link

Display id change after operation #44

Closed petitchamp closed 3 months ago

petitchamp commented 4 months ago

I have 3 monitors when I run ToogleDisplay list

toggledisplay LIST \.\DISPLAY1 -> DELL P2422H (\?\DISPLAY#DELA1C4#5&1f90b8c9&0&UID4354#{e6f07b5f-ee97-4a90-b076-33f57bf4eaa7}) [enabled] (w: 1920; h: 1080; x: -1920; y: 0) \.\DISPLAY2 -> DELL P2422H (\?\DISPLAY#DELA1C4#5&1f90b8c9&0&UID4352#{e6f07b5f-ee97-4a90-b076-33f57bf4eaa7}) [enabled] (w: 1920; h: 1080; x: 1920; y: 0) \.\DISPLAY3 -> DELL P2424HEB (\?\DISPLAY#DEL42BD#5&1f90b8c9&0&UID4651#{e6f07b5f-ee97-4a90-b076-33f57bf4eaa7}) [enabled] (w: 1920; h: 1080; x: 0; y: 0)

But after disabling display 2 and 3, their ids changed call toggledisplay DISABLE \\.\DISPLAY2 call timeout /T 5 call toggledisplay DISABLE \\.\DISPLAY3

toggledisplay LIST

\.\DISPLAY1 -> DELL P2422H (\?\DISPLAY#DELA1C4#5&1f90b8c9&0&UID4354#{e6f07b5f-ee97-4a90-b076-33f57bf4eaa7}) [enabled] (w: 1920; h: 1080; x: 0; y: 0) \.\DISPLAY2 -> DELL P2422H (\?\DISPLAY#DELA1C4#5&1f90b8c9&0&UID4352#{e6f07b5f-ee97-4a90-b076-33f57bf4eaa7}) [disabled] \.\DISPLAY2 -> DELL P2424HEB (\?\DISPLAY#DEL42BD#5&1f90b8c9&0&UID4651#{e6f07b5f-ee97-4a90-b076-33f57bf4eaa7}) [disabled]

sgrottel commented 4 months ago

Yes, I can confirm that this happens.

The display name (e.g. \\.\DISPLAY1) is automatically assigned by Windows. Apparently, it can change whenever Windows feels like it. Note: this is a logical construct of the combination of a graphics adapter, it's connector, and the target display device.

The display device name (e.g. DELL P2422H) and device path (e.g. \\?\DISPLAY#DELA1C4#5&1f90b8c9&0&UID4354#{e6f07b5f-ee97-4a90-b076-33f57bf4eaa7}) are stable, as those are representatives of the real hardware.

I recommend using the device name or device path (in case the device name is not unique):

ToggleDisplay.exe toggle "\\?\DISPLAY#DELA1C4#5&1f90b8c9&0&UID4352#{e6f07b5f-ee97-4a90-b076-33f57bf4eaa7}"
petitchamp commented 3 months ago

thank you for your reply. It works much better with device path