2

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
asked Jul 15, 2021 at 17:21
1

1 Answer 1

3

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.
answered Jan 5, 2022 at 16:44
2
  • 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. Commented 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 :) Commented Jan 5, 2022 at 17:03

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.