patrick-theprogrammer / WindowsDisplayManager

A powershell module for managing Windows display settings.
https://www.powershellgallery.com/packages/WindowsDisplayManager
MIT License
17 stars 1 forks source link

Can't enable disabled monitor #2

Open Cynary opened 4 months ago

Cynary commented 4 months ago

If a monitor is disabled when I run GetAllPotentialDisplays, I have no way to enable it. But if I use an earlier returned value, it works. Here's an easy repro:

# display 0 is enabled
$displays = WindowsDisplayManager\GetAllPotentialDisplays
$displays[0].disable() # Returns True, display 0 is disabled now.
$displays[0].enable() # Returns True, display 0 is enabled now.
$displays[0].disable() # Returns True, display 0 is disabled now.
$displays = WindowsDisplayManager\GetAllPotentialDisplays # display 0 now has no target.
$displays[0].enable() # Returns True, but nothing happens.

Output with display 0 enabled:

Display ID   Description            Active  Enabled  Primary  Resolution           HDR Info               Position   Recommended Resolution   Source                       Target
----------   -----------            ------  -------  -------  ----------           --------               --------   ----------------------   ------                       ------
0-4353       AW3423DWF via NVIDIA   True    True     False    Width       : 3440   HdrSupported : True    X : 3840   Width  : 3440            Id          : 0              Id             : 4353
             GeForce RTX 4090                                 Height      : 1440   HdrEnabled   : True    Y : 0      Height : 1440            Name        : \\.\DISPLAY1   FriendlyName   : AW3423DWF
                                                              RefreshRate : 60     BitDepth     : 10                                          Description : NVIDIA         ConnectionType :
                                                                                                                                              GeForce RTX 4090             DisplayportExternal
1            Unconnected NVIDIA     True    False    True     Width       : 3840   N/A                    X : 0      N/A                      Id          : 1              None
             GeForce RTX 4090                                 Height      : 2160                          Y : 0                               Name        : \\.\DISPLAY2
             source                                           RefreshRate : 120                                                               Description : NVIDIA
                                                                                                                                              GeForce RTX 4090
2            Unconnected NVIDIA     False   False    False    N/A                  N/A                    N/A        N/A                      Id          : 2              None
             GeForce RTX 4090                                                                                                                 Name        : \\.\DISPLAY3
             source                                                                                                                           Description : NVIDIA
                                                                                                                                              GeForce RTX 4090
3            Unconnected NVIDIA     False   False    False    N/A                  N/A                    N/A        N/A                      Id          : 3              None
             GeForce RTX 4090                                                                                                                 Name        : \\.\DISPLAY4
             source                                                                                                                           Description : NVIDIA
                                                                                                                                              GeForce RTX 4090

Output with display 0 disabled:

Display ID   Description            Active  Enabled  Primary  Resolution           HDR Info               Position   Recommended Resolution   Source                       Target
----------   -----------            ------  -------  -------  ----------           --------               --------   ----------------------   ------                       ------
0            Unconnected NVIDIA     False   False    False    N/A                  N/A                    N/A        N/A                      Id          : 0              None
             GeForce RTX 4090                                                                                                                 Name        : \\.\DISPLAY1
             source                                                                                                                           Description : NVIDIA
                                                                                                                                              GeForce RTX 4090
1-4352       DENON-AVR via NVIDIA   True    True     True     Width       : 3840   HdrSupported : True    X : 0      Width  : 3840            Id          : 1              Id             : 4352
             GeForce RTX 4090                                 Height      : 2160   HdrEnabled   : True    Y : 0      Height : 2160            Name        : \\.\DISPLAY2   FriendlyName   : DENON-AVR
                                                              RefreshRate : 120    BitDepth     : 10                                          Description : NVIDIA         ConnectionType : Hdmi
                                                                                                                                              GeForce RTX 4090
2            Unconnected NVIDIA     False   False    False    N/A                  N/A                    N/A        N/A                      Id          : 2              None
             GeForce RTX 4090                                                                                                                 Name        : \\.\DISPLAY3
             source                                                                                                                           Description : NVIDIA
                                                                                                                                              GeForce RTX 4090
3            Unconnected NVIDIA     False   False    False    N/A                  N/A                    N/A        N/A                      Id          : 3              None
             GeForce RTX 4090                                                                                                                 Name        : \\.\DISPLAY4
             source                                                                                                                           Description : NVIDIA
                                                                                                                                              GeForce RTX 4090