This is a clumsy workaround using AutoHotKey in case you did not find a direct answer. You can use a script to retrace the steps of manually switching the layouts. The sequance may differ from system to system so I will list the instructions along with a sample script that works on mine:
- Open the Screen Resolution window, and press (on the keyboard) the number of the screen you'd like to edit. 2 for example
- Count how many Tab presses it takes to reach the Multiple Displays menu. This number will change depending on the mode it's already in
- Use the first letter of the menu entry to select it. E for extend, D for duplicate, etc...
- Again count how many Tab presses it takes to reach the OK button
When you have all the variables, use them to modify the configuration section of this AutoHotKey script:
;; Configuration
myWinTitle := "Screen Resolution" ;; Title of the window
dSequence := "2{Tab 4}d{Tab 6}{Enter}" ;; Key sequence for duplicating displays
eSequence := "2{Tab 2}e{Tab 8}{Enter}" ;; Key sequence for extending displays
;; End of configuration section
#NoEnv
SendMode Input
SetTitleMatchMode, 2
#+d::
Run control desk.cpl
IfWinNotActive, %myWinTitle%, , WinActivate, %myWinTitle%,
WinWaitActive, %myWinTitle%,
Send %dSequence%
return
#+e::
Run control desk.cpl
IfWinNotActive, %myWinTitle%, , WinActivate, %myWinTitle%,
WinWaitActive, %myWinTitle%,
Send %eSequence%
return
The hotkey Win+Shift+D should now switch to duplicate displays (by quickly retracing your steps), and Win+Shift+E should swtich back to extended displays.
There are most likely cleaner ways to do this by directly editing the registery keys. I'll update the script if I figure it out.