Context: Windows 10 Desktop PC "losing track" of screens, and they go/stay black
I want to mimic the effect of "changing the Windows Display config" (see end for the specific UI navigation) on a command line, so that I can set it up such that I can easily run the command/script with Keyboard only, without access to the monitors.
All I need is a script or exe that can do this, and then either I can use my keyboard's has programmable F-Keys, or I could do:
- Win-Key
- type "cmd"
- Enter
- type "reset_screens.sh/.cmd/.ps1/.exe/.whatever"
- Enter
So, how can I reproduce the effect of that UI interaction without the UI?
UI Sequence:
- Minimise everything down to desktop
- Context Menu for desktop background
- "Display Settings"
- Scroll down to "Multiple Displays".
- In the drop down change from "Extend these displays" to "Duplicate these display".
- What happens after that is irrelevant, as long as it then gets reversed
-
1These seem like promising links, but I haven't yet identified anything specificaly in them that would solve it :( (And I know that link-only answers aren't considered appropriate :D) codeproject.com/Articles/36664/… stackoverflow.com/questions/233411/…Brondahl– Brondahl2021年07月15日 17:29:53 +00:00Commented Jul 15, 2021 at 17:29
1 Answer 1
There is a command that can do it called: DISPLAYSWITCH.exe Note this is the program that opens when you press Windows+P
I don't know how it works internally, but you can call it from C#.
The WIN32 command for updating these display settings seems to be: SetDisplayConfig
Syntax DISPLAYSWITCH /Option
Options
/internal Switch to use the primary display only.
1 All other connected displays will be disabled.
/clone The primary display will be mirrored on a second screen.
2
/extend Expand the Desktop to a secondary display.
3 This allows one desktop to span multiple displays. (Default).
/external Switch to the external display only (second screen).
4 The current main display will be disabled.
-
Ooh! An exciting new development ... I'll take a look at this at some point in the (hopefully not too distant future) and accept if it works for me.Brondahl– Brondahl2022年01月05日 17:02:56 +00:00Commented Jan 5, 2022 at 17:02
-
Feel free to intermittently ping me if I haven't come back to accept / refute this after a few weeks :)Brondahl– Brondahl2022年01月05日 17:03:37 +00:00Commented Jan 5, 2022 at 17:03
You must log in to answer this question.
Explore related questions
See similar questions with these tags.