Scripts and guide to automatic monitor configuration when streaming with Sunshine/Moonlight on Windows.
- Click "Download ZIP" in the top-right corner of this Gist, and extract scripts to e.g.
C:/(or a directory of your choosing) - Download MultiMonitorTool
- Place scripts and
MultiMonitorTool.exein a directory next to your scripts, or add the tool to your system$PATH - Modify your Sunshine "Do command" and "Undo command"
# Do Command
powershell.exe C:/Set-SunshineDo.ps1
# Undo Command
powershell.exe C:/Set-SunshineUndo.ps1Next, modify Set-SunshineDo.ps1 and Set-SunshineUndo.ps1 (see below for how to find "
ID"). You can run e.g. Get-Help -Detailed .\Set-Monitors.ps1 to see what each parameter means. Note that these scripts use argument splatting for legibility, and is equivalent to the usual command-line syntax e.g. Set-Monitors.ps1 ... -Width 1920 -Height 1080.
- Modify or remove the
Toolargument, depending on where you putMultiMonitorTool.exe - Replace
<YOUR_PRIMARY_MONITOR_SHORT_ID> - Remove the line for
Disableif desired, or provide<SECONDARY_MONITOR_SHORT_ID_TO_DISABLE>(you may also provide an array of strings to enable/disable multiple monitors, e.g.'<FIRST_MONITOR_TO_DISABLE>', '<SECOND MONITOR TO DISABLE>') - Set
Width,Height, and optionally,Scalefor your setup - Optionally,
MoveorMaximizeall windows to the primary monitor
See screenshots below for how to find the "Short Monitor ID" for your monitors. The Primary argument defaults to 'Primary', but this sometimes selects the wrong monitor so you should set it to the explicit "Short Monitor ID" of your primary monitor.
The Disable and Enable arguments are optional, in some cases disabling a secondary monitor when streaming Sunshine can reduce the occurrence of momentary "bitrate warning" freeze-ups on e.g. Moonlight clients. You could use e.g. \\.\DISPLAY3 to refer to Disable or Enable monitors (or Primary), but this sometimes disables the wrong monitor, so use the explicit "Short Monitor ID" of the monitor you may wish to disable.


