Releases: Nonary/MonitorSwapAutomation
v2.0.3
README
This tool automatically switches your main display to a dummy plug (or any virtual display) that you have set up for Sunshine. The goal is to seamlessly switch from your normal monitor setup to a dummy display when you start streaming (e.g., using Moonlight on a mobile device).
How It Works
- Normal Operation: When you’re not streaming, your PC uses your regular monitor arrangement.
- While Streaming: As soon as you start a Moonlight stream on another device, the script automatically switches to a dummy monitor configuration (or another specified monitor layout).
Important Notes
-
Dummy Plug / Virtual Display:
This script is designed for systems with a dummy plug or virtual display, but it can be used in other scenarios. For instance, you can use it to switch from a dual-monitor setup to a single monitor while streaming. -
Windows 11 Users:
Due to a known bug, you must set the default terminal to Windows Console Host.-
On newer Windows 11 versions:
- Open Settings.
- Go to System > For Developers.
- Locate the Terminal setting (which defaults to "Let Windows decide").
- Change it to Terminal [Windows Console Host].
-
On older Windows 11 versions:
- Open Settings.
- Go to Privacy & Security > Security > For Developers.
- Find the Terminal option.
- Change it from "Let Windows decide" to Terminal [Windows Console Host].
Without this setting, the script may not work correctly.
-
-
Do Not Move the Script’s Folder After Installation:
If you move the installation folder after setting up the script, it may stop working. In that case, simply reinstall it. -
Cold Reboots / Hard Crashes Issue:
On a cold boot (from a fully powered-off state), Windows may not allow the script to switch monitors immediately.Workaround:
- After a cold boot, start your PC and log in using the "Desktop" stream option in Moonlight.
- End the stream, then start it again.
After doing this once, subsequent uses should work normally.
-
Sunshine Web UI Setting:
Do not set an “Output Name” in the Sunshine Web UI under the Audio/Video tab. Leave it blank. Setting an output name may break the script’s functionality.
Requirements
-
For GFE (GeForce Experience) Users:
This script no longer supports GFE. If you need the older version that worked with GFE, download the Legacy Version. -
For Sunshine Users:
- Sunshine version 0.19.1 or higher.
- Host computer must be running Windows.
Step-by-Step Setup for Monitor Configuration
-
Sunshine Output Settings:
- In the Sunshine Web UI, ensure the “Output Name” field is blank under Audio/Video settings.
-
Install the Script:
- Follow the provided installer instructions to set up the script on your computer.
-
Set Your Baseline (Primary) Monitor Setup:
- Arrange your monitors as desired for normal operation (e.g., when you’re not streaming).
-
Save Your “Primary” Monitor Profile:
- Open Terminal/Command Prompt in the script’s folder.
- Run the following command:
.\MonitorSwitcher.exe -save:Primary.xml
- This creates a snapshot of your current monitor configuration as
Primary.xml
.
-
Prepare to Save Your “Dummy” Monitor Profile:
- Start a Moonlight stream from another device (e.g., phone, tablet) so you can view and control your PC remotely.
- This is essential because your physical monitor will go dark when switching to the dummy monitor.
-
Configure the Dummy Monitor Setup (While Streaming):
- With the remote stream running:
- On your Windows PC, open Settings > System > Display.
- Click Identify to determine the monitor number for streaming. For a dummy plug, identify the monitor number that is not physically visible.
- If multiple monitors are active, disconnect secondary monitors:
- Select the monitor to disconnect (e.g., monitor #2).
- Use the dropdown menu to choose Disconnect this display.
- Repeat until only the primary monitor is active.
- Ensure you are remotely viewing the PC on another device before proceeding, as you will not be able to see the screen physically on this next step.
- In Display settings, set the dropdown to Show only on {NUMBER}, where
{NUMBER}
is the dummy/streaming monitor. - If you do not see Show only on {NUMBER}
- Select the dummy display, then click the dropdown and select "Extend desktop to this display"
- Select the dummy display again and expand the "Multiple Displays" group (if not already done)
- Click the "Make this my main display" checkbox
- Click your other monitor that was previously the main display, then click the dropdown again, then click "Disconnect this display".
- While at your computer confirm the display settings by clicking "Keep Changes", use your other device that is currently streaming for guidance on moving the mouse.
- With the remote stream running:
-
Save Your “Dummy” Monitor Profile:
- In the Terminal (still in the script’s folder), run the following command:
.\MonitorSwitcher.exe -save:Dummy.xml
- This saves your dummy/streaming monitor configuration as
Dummy.xml
.
- In the Terminal (still in the script’s folder), run the following command:
-
Completing the Setup:
- End the Moonlight stream session.
- Your display should revert to the original configuration on your physical monitor.
Now, the script will automatically switch to the dummy display configuration when streaming and restore your original setup when you stop streaming.
Troubleshooting
If the ResolutionAutomation script doesn’t switch resolutions properly or is unreliable:
- Increase the start delay in settings.json (located in the script’s folder) to 3 or 4 seconds. This gives the monitor-switching process more time before the resolution change occurs.
Change Log
v2.0.3
- Fixed another bug that caused script to exit earlier than intended before restoring primary monitor.
v2.0.2
- More bug fixes that prevented primary monitor from restoring after a stream was ended.
v2.0.1
- Fixed a bug that prevented the primary monitor from restoring after ending a stream.
v2.0.0
- Switched from Nirsoft MultiMonitorTool to MonitorSwitcher for better compatibility with Windows 24H2 and improved reliability.
v1.2.0
- Added changes to support Hybrid GPU fixes, assisting laptop users in forcing NVIDIA encoding.
v1.1.9
- Updated MultiMonitorTool to v2.10.
- Improved validation for restoring primary monitors.
v2.0.2
README
This tool automatically switches your main display to a dummy plug (or any virtual display) that you have set up for Sunshine. The goal is to seamlessly switch from your normal monitor setup to a dummy display when you start streaming (e.g., using Moonlight on a mobile device).
How It Works
- Normal Operation: When you’re not streaming, your PC uses your regular monitor arrangement.
- While Streaming: As soon as you start a Moonlight stream on another device, the script automatically switches to a dummy monitor configuration (or another specified monitor layout).
Important Notes
-
Dummy Plug / Virtual Display:
This script is designed for systems with a dummy plug or virtual display, but it can be used in other scenarios. For instance, you can use it to switch from a dual-monitor setup to a single monitor while streaming. -
Windows 11 Users:
Due to a known bug, you must set the default terminal to Windows Console Host.-
On newer Windows 11 versions:
- Open Settings.
- Go to System > For Developers.
- Locate the Terminal setting (which defaults to "Let Windows decide").
- Change it to Terminal [Windows Console Host].
-
On older Windows 11 versions:
- Open Settings.
- Go to Privacy & Security > Security > For Developers.
- Find the Terminal option.
- Change it from "Let Windows decide" to Terminal [Windows Console Host].
Without this setting, the script may not work correctly.
-
-
Do Not Move the Script’s Folder After Installation:
If you move the installation folder after setting up the script, it may stop working. In that case, simply reinstall it. -
Cold Reboots / Hard Crashes Issue:
On a cold boot (from a fully powered-off state), Windows may not allow the script to switch monitors immediately.Workaround:
- After a cold boot, start your PC and log in using the "Desktop" stream option in Moonlight.
- End the stream, then start it again.
After doing this once, subsequent uses should work normally.
-
Sunshine Web UI Setting:
Do not set an “Output Name” in the Sunshine Web UI under the Audio/Video tab. Leave it blank. Setting an output name may break the script’s functionality.
Requirements
-
For GFE (GeForce Experience) Users:
This script no longer supports GFE. If you need the older version that worked with GFE, download the Legacy Version. -
For Sunshine Users:
- Sunshine version 0.19.1 or higher.
- Host computer must be running Windows.
Step-by-Step Setup for Monitor Configuration
-
Sunshine Output Settings:
- In the Sunshine Web UI, ensure the “Output Name” field is blank under Audio/Video settings.
-
Install the Script:
- Follow the provided installer instructions to set up the script on your computer.
-
Set Your Baseline (Primary) Monitor Setup:
- Arrange your monitors as desired for normal operation (e.g., when you’re not streaming).
-
Save Your “Primary” Monitor Profile:
- Open Terminal/Command Prompt in the script’s folder.
- Run the following command:
.\MonitorSwitcher.exe -save:Primary.xml
- This creates a snapshot of your current monitor configuration as
Primary.xml
.
-
Prepare to Save Your “Dummy” Monitor Profile:
- Start a Moonlight stream from another device (e.g., phone, tablet) so you can view and control your PC remotely.
- This is essential because your physical monitor will go dark when switching to the dummy monitor.
-
Configure the Dummy Monitor Setup (While Streaming):
- With the remote stream running:
- On your Windows PC, open Settings > System > Display.
- Click Identify to determine the monitor number for streaming. For a dummy plug, identify the monitor number that is not physically visible.
- If multiple monitors are active, disconnect secondary monitors:
- Select the monitor to disconnect (e.g., monitor #2).
- Use the dropdown menu to choose Disconnect this display.
- Repeat until only the primary monitor is active.
- This is required in order to see the Show only on {NUMBER} options.
- Ensure you are remotely viewing the PC on another device before proceeding, as you will not be able to see the screen physically on this next step.
- In Display settings, set the dropdown to Show only on {NUMBER}, where
{NUMBER}
is the dummy/streaming monitor. - While at your computer confirm the display settings by clicking "Keep Changes", use your other device that is currently streaming for guidance on moving the mouse.
- With the remote stream running:
-
Save Your “Dummy” Monitor Profile:
- In the Terminal (still in the script’s folder), run the following command:
.\MonitorSwitcher.exe -save:Dummy.xml
- This saves your dummy/streaming monitor configuration as
Dummy.xml
.
- In the Terminal (still in the script’s folder), run the following command:
-
Completing the Setup:
- End the Moonlight stream session.
- Your display should revert to the original configuration on your physical monitor.
Now, the script will automatically switch to the dummy display configuration when streaming and restore your original setup when you stop streaming.
Troubleshooting
If the ResolutionAutomation script doesn’t switch resolutions properly or is unreliable:
- Increase the start delay in settings.json (located in the script’s folder) to 3 or 4 seconds. This gives the monitor-switching process more time before the resolution change occurs.
Change Log
v2.0.2
- More bug fixes that prevented primary monitor from restoring after a stream was ended.
v2.0.1
- Fixed a bug that prevented the primary monitor from restoring after ending a stream.
v2.0.0
- Switched from Nirsoft MultiMonitorTool to MonitorSwitcher for better compatibility with Windows 24H2 and improved reliability.
v1.2.0
- Added changes to support Hybrid GPU fixes, assisting laptop users in forcing NVIDIA encoding.
v1.1.9
- Updated MultiMonitorTool to v2.10.
- Improved validation for restoring primary monitors.
v1.1.8
- Added debug logging.
- Fixed monitor flicker issue related to known workarounds.
v2.0.1
This tool automatically switches your main display to a dummy plug (or any virtual display) that you have set up for Sunshine. The goal is to seamlessly switch from your normal monitor setup to a dummy display when you start streaming (e.g., using Moonlight on a mobile device).
How It Works
- Normal Operation: When you’re not streaming, your PC uses your regular monitor arrangement.
- While Streaming: As soon as you start a Moonlight stream on another device, the script automatically switches to a dummy monitor configuration (or another specified monitor layout).
Important Notes
-
Dummy Plug / Virtual Display:
This script is designed for systems with a dummy plug or virtual display, but it can be used in other scenarios. For instance, you can use it to switch from a dual-monitor setup to a single monitor while streaming. -
Windows 11 Users:
Due to a known bug, you must set the default terminal to Windows Console Host.-
On newer Windows 11 versions:
- Open Settings.
- Go to System > For Developers.
- Locate the Terminal setting (which defaults to "Let Windows decide").
- Change it to Terminal [Windows Console Host].
-
On older Windows 11 versions:
- Open Settings.
- Go to Privacy & Security > Security > For Developers.
- Find the Terminal option.
- Change it from "Let Windows decide" to Terminal [Windows Console Host].
Without this setting, the script may not work correctly.
-
-
Do Not Move the Script’s Folder After Installation:
If you move the installation folder after setting up the script, it may stop working. In that case, simply reinstall it. -
Cold Reboots / Hard Crashes Issue:
On a cold boot (from a fully powered-off state), Windows may not allow the script to switch monitors immediately.Workaround:
- After a cold boot, start your PC and log in using the "Desktop" stream option in Moonlight.
- End the stream, then start it again.
After doing this once, subsequent uses should work normally.
-
Sunshine Web UI Setting:
Do not set an “Output Name” in the Sunshine Web UI under the Audio/Video tab. Leave it blank. Setting an output name may break the script’s functionality.
Requirements
-
For GFE (GeForce Experience) Users:
This script no longer supports GFE. If you need the older version that worked with GFE, download the Legacy Version. -
For Sunshine Users:
- Sunshine version 0.19.1 or higher.
- Host computer must be running Windows.
Step-by-Step Setup
-
Sunshine Output Settings:
In the Sunshine Web UI, ensure the “Output Name” field is blank under Audio/Video settings. -
Install the Script:
Follow the provided installer instructions to set up the script on your computer. -
Set Your Baseline (Primary) Monitor Setup:
Arrange your monitors exactly how you want them for normal operation (i.e., when you’re not streaming). -
Save Your “Primary” Monitor Profile:
- Open Terminal/Command Prompt in the script’s folder.
- Run:
.\MonitorSwitcher.exe -save:Primary.xml
This creates a snapshot of your current (normal) monitor configuration as “Primary.xml.”
-
Prepare to Save Your “Dummy” Monitor Profile:
Start a Moonlight stream from another device (phone, tablet, etc.) so you can view and control your PC remotely. This is important because when you switch to the dummy monitor, your physical monitor will go dark. -
Configure the Dummy Monitor Setup (While Streaming):
- With the remote stream running:
- On your Windows PC, open Settings > System > Display.
- Click Identify to determine the monitor number you want to use for streaming. For a dummy plug, identify which monitor number is not physically visible.
- In the display settings, change the dropdown to "show only on {NUMBER}" where {NUMBER} is the monitor you plan to use as the dummy/streaming display.
- Once you confirm this change, your local display goes black. Continue using your remote device to control the PC.
- With the remote stream running:
-
Save Your “Dummy” Monitor Profile:
- Back in your Terminal window (still in the script’s folder), run:
.\MonitorSwitcher.exe -save:Dummy.xml
This saves your dummy/streaming monitor setup as “Dummy.xml.”
- Back in your Terminal window (still in the script’s folder), run:
-
Completing the Setup:
- End the Moonlight stream session.
- Your display should return to normal on your physical monitor.
Now, whenever you start a stream, the script automatically switches to the dummy display configuration. When you stop streaming, it will restore your original setup.
Troubleshooting
If the ResolutionAutomation script doesn’t switch resolutions properly or is unreliable:
- Increase the start delay in settings.json (located in the script’s folder) to 3 or 4 seconds. This gives the monitor-switching process more time before the resolution change occurs.
Change Log
v2.0.1
- Fixed a bug that prevented the primary monitor from restoring after ending a stream.
v2.0.0
- Switched from Nirsoft MultiMonitorTool to MonitorSwitcher for better compatibility with Windows 24H2 and improved reliability.
v1.2.0
- Added changes to support Hybrid GPU fixes, assisting laptop users in forcing NVIDIA encoding.
v1.1.9
- Updated MultiMonitorTool to v2.10.
- Improved validation for restoring primary monitors.
v1.1.8
- Added debug logging.
- Fixed monitor flicker issue related to known workarounds.
v1.1.7 & v1.1.6
- Various fixes for file handling, profile restoration, and logging.
- Integrated updates from the SunshineScript Installer template.
v2.0
README
This tool helps automatically switch your main display between a “real” monitor and a “dummy” monitor when streaming with Sunshine.
Key Idea:
- When you’re not streaming, your computer uses your normal monitor setup.
- When you start streaming (for example, using a mobile device to control your PC remotely with Moonlight), the script will switch to a dummy monitor.
Important Notes
-
Windows 11 Users:
Due to a bug, you must set the default terminal to Windows Console Host.-
On newer Windows 11 versions:
- Open Settings
- Go to System > For Developers
- Find the Terminal setting that says "Let Windows decide"
- Change it to Terminal [Windows Console Host]
-
On older Windows 11 versions:
- Open Settings
- Go to Privacy & Security > Security > For Developers
- Find the Terminal option and change it from "Let Windows decide" to Terminal [Windows Console Host].
This is required for the script to work properly.
-
-
Do Not Move the Script’s Folder:
If you move the folder after installing, the script may stop working. If that happens, just reinstall it. -
Cold Reboots (Hard Crash or Full Shutdown) Issue:
If you start your computer from a completely off state (a “cold boot”), the script cannot automatically switch the monitor right away due to Windows limitations.
Workaround:- After a cold boot, sign into your PC using the “Desktop” app on Moonlight.
- Then end the stream and start it again.
After doing this once, the script will work normally again on subsequent uses.
-
Sunshine WEB UI Setting:
In the Sunshine Web UI, do not fill in the “Output Name” under the Audio/Video tab. Leave it blank.
If you set an output name, it can break how this script works.
Requirements
-
For GFE (GeForce Experience) Users:
This script no longer supports GFE. If you need the old version that works with GFE, get it here:
Legacy Version Download -
For Sunshine Users:
- You need Sunshine version 0.19.1 or higher
- Host computer must be running Windows.
Step-by-Step Instructions
-
IMPORTANT: Erase Display Output Settings on Sunshine WEB UI
In the Sunshine Web UI, do not fill in the “Output Name” under the Audio/Video tab. Leave it blank.
If you set an output name, it can break how this script works. -
Install the Script:
Follow the instructions provided with the script or the installer to get it set up on your computer. -
Set Your Desired Baseline Monitor Setup:
Before saving any profiles, make sure your monitors are arranged exactly how you want them when you’re not streaming. This will be your “normal” setup. -
Save Your “Primary Monitor” Profile:
- Open a Terminal/Command Prompt window in the folder where you saved the script.
- Type:
.\MonitorSwitcher.exe -save:Primary.xml
This command saves a snapshot of your current monitor setup as “Primary.xml.”
-
Prepare to Save Your “Dummy Monitor” Profile:
Now you need to start a Moonlight stream from another device (like your phone or tablet) so you can see your PC’s screen even if the actual monitor goes black. -
Switch to the Dummy Monitor Setup (While Streaming):
- With the stream running and using your other device to view your computer:
- On your Windows PC, go to Settings > System > Display.
- Change the setting to show only on the dummy display. (This might make your physical monitor go dark, but you’ll still see your PC screen on your remote device.)
Now your PC is using the dummy monitor as the “main display.”
- With the stream running and using your other device to view your computer:
-
Save Your “Dummy Monitor” Profile:
- While still in the folder on your PC (visible via your remote device), open Terminal again and type:
.\MonitorSwitcher.exe -save:Dummy.xml
- While still in the folder on your PC (visible via your remote device), open Terminal again and type:
-
Finish Up:
- End the stream on your mobile or remote device.
- Your display should now return to normal on your physical monitor.
From now on, every time you start a stream, the script will automatically switch to the dummy display, and when you end the stream, it will switch back to your normal setup.
Troubleshooting
Problem: ResolutionAutomation Script Doesn’t Change Resolution or Works Intermittently
-
First, ensure you installed MonitorSwapper first, and then the ResolutionAutomation script after.
If you did it the other way around, uninstall both, then install MonitorSwapper first and ResolutionAutomation second. -
If you still have issues, try increasing the start delay in the settings.json file (found in the script’s folder) to 3 or 4 seconds. This gives the monitor swap process more time to complete before the resolution attempts to change.
Change Log
v2.0.0
- Changed the script’s backend from Nirsoft MultiMonitorTool to MonitorSwitcher to address compatibility issues with Windows 24H2 and improve reliability.
v1.2.0
- Added support changes required for Hybrid GPU fixes, helping laptop users force NVIDIA encoding.
v1.1.9
- Updated MultiMonitorTool to v2.10 and added stricter validation for restoring primary monitors.
v1.1.8
- Added debug logging to help troubleshoot issues.
- Fixed a monitor flicker issue related to a known workaround.
v1.1.7 & v1.1.6
- Various fixes to improve file handling, profile restoration, and logging.
- Integrated updates from the SunshineScript Installer template.
v1.2.2
README
This script automates the process of switching your primary monitor with a dummy monitor using MultiMonitorTool.
This is useful for users of Sunshine (a screen sharing software) who experience issues with sharing their primary monitor.
Caveats:
- If using Windows 11, you'll need to set the default terminal to Windows Console Host as there is currently a bug in Windows Terminal that prevents hidden consoles from working properly.
- That can be changed at Settings > System > For Developers > Terminal [Let Windows decide] >> (change to) >> Terminal [Windows Console Host]
- On older versions of Windows 11 it can be found at: Settings > Privacy & security > Security > For developers > Terminal [Let Windows decide] >> (change to) >> Terminal [Windows Console Host]
- The script will stop working if you move the folder, simply reinstall it to resolve that issue.
- Due to Windows API restrictions, this script does not work on cold reboots (hard crashes or shutdowns of your computer).
- If you're cold booting, simply sign into the computer using the "Desktop" app on Moonlight, then end the stream, then start it again.
- In the Sunshine WEB UI, make sure you leave the Output Name blank under the Audio/Video tab, otherwise it could cause breaking behavior with this script.
REQUIREMENTS
For GFE users
- This script no longer supports GFE, but you are able to retrieve a legacy version of this script that does support it: https://github.com/Nonary/MonitorSwapAutomation/releases/tag/legacy
For Sunshine users
- Version 0.19.1 or higher
- Host must be Windows
INSTRUCTIONS
-
Open up MultiMonitorTool and click on
File -> Save Monitors Configuration
and save it in the current folder this script is located in with the name ofprimary.cfg
. -
Repeat the same steps of step 1, except save it with the name of
dummy.cfg
. -
Open up the
dummy.cfg
file and set every parameter related to your primary monitor's position, refresh rate, etc. to0
. For example:Name=\\.\DISPLAY1 MonitorID=MONITOR\GSMC0C8\{4d36e96e-e325-11ce-bfc1-08002be10318}\0009 SerialNumber=LGTV BitsPerPixel=0 Width=0 Height=0 DisplayFlags=0 DisplayFrequency=0 DisplayOrientation=0 PositionX=0 Name=\\.\DISPLAY11 MonitorID=MONITOR\XMD29831\{4d36e96e-e325-11ce-bfc1-08002be10318}\0007 SerialNumber=DUMMY BitsPerPixel=32 Width=3840 Height=2160 DisplayFlags=0 DisplayFrequency=120 DisplayOrientation=0 PositionX=0
In the example above, every numerical value has been set to 0, which lets the script know that the display should be turned off.
Also take note in the example, that my dummy display should have values configured to let it know that it should be turned on. -
Verify that the
dummy.cfg
file has only one display that contains values for theBitsPerPixel
,Width
,Height
, and so on.
4a. For theprimary.cfg file
, it does not matter if there are other displays enabled, but you would want to make sure your dummy is "zeroed out" so you don't end up with an invisible monitor. -
Basically, primary will "zero out" the dummy plug, and dummy will "zero out" the main display. This will automatically transfer games and windows back to the primary monitor if setup this way.
-
In the
dummy.cfg
file, locate your dummyMonitorId
and copy and paste it to thedummyMonitorId
key in the settings.json file. Make sure to escape the backslashes. -
Validate you have escaped the backslashes, below is an example of a valid settings.json file.
{ "startDelay": 2, "gracePeriod": 60, "configSaveLocation": "%TEMP%", "dummyMonitorId": "MONITOR\\XMD009A\\{4d36e96e-e325-11ce-bfc1-08002be10318}\\0010" }
-
Install the script by double clicking the Install.bat file, you may get a smart-screen warning... this is normal.
-
You will be prompted for administrator rights, as modifying Sunshine configuration will require admin rights in the coming future.
-
If there are no error messages presented on the screen, the script successfully installed and you can close the terminal.
The paths referenced above will vary on your machine.
TROUBLESHOOTING
If you encounter issues with the script, you can try the following:
Monitor is not swapping before stream or afterwards
-
Check that your dummy monitor
MonitorId
matches the value in thedummyMonitorId
variable in thesettings.json
file. -
Check that you have escaped the backslashes for dummyMonitorId in the
settings.json
file.
Valid: MONITOR\\GSMC0C8\\{4d36e96e-e325-11ce-bfc1-08002be10318}\\0009Invalid: MONITOR\GSMC0C8{4d36e96e-e325-11ce-bfc1-08002be10318}\0009
-
Check that you have set every parameter related to the primary monitor's resolution in the
dummy.cfg
file to0
. -
Check that you have set every parameter related to the dummy monitor's resolution in the
primary.cfg
file to0
. -
Check that you have at least one monitor not "zeroed out" in both the primary.cfg and dummy.cfg files.
-
Ensure that you have followed the requirements for Sunshine users as listed above.
-
Increase the startDelay in the settings file if you're experiencing the script only works intermitently.
-
If you are still experiencing issues, try uninstalling and installing it again.
ResolutionAutomation script isn't changing my resolution after connecting and or is intermittently working
- First, ensure that MonitorSwapper is installed first, then install the ResolutionAutomation script.
- If you installed them out of order, uninstall both, then install MonitorSwapper, then ResolutionAutomation.
- Adjust the start delay in the settings.json file to 3 or 4 seconds and that should resolve that issue.
- Sometimes the swap can take longer to do and the resolution swap is happening on your primary screen
- Adjusting the start delay will give the swap more time to complete, thus making sure resolution is changed on the correct monitor.
Only One Screen is Being Restored, Everything Else Works
- You will have to follow the workaround mentioned here: MonitorSwapAutomation Issue #9
- There is currently a bug in the MultiMonitor tool affecting users with dual screens. I do not have the source code for that tool, so it is impossible for me to fix directly. A workaround is necessary until Nirsoft resolves this issue. Please report your issue to nirsofer@yahoo.com so he can gather more users and data to ultimately resolve this issue.
Primary Monitor Wasn't Restored
Check the logs to see if they claim the primary monitor was successfully restored. If it was, enable enableStrictRestoration
in the settings.json
file by setting it to true
. If the logs do not show it restored, it probably was closed out before the script could finish (in the case of reboots). In such cases, you can't do much to resolve it other than ensuring you do not reboot before returning to your machine.
Resolution Change When Resuming or Starting a New Stream
- Double-check and ensure you have put the correct
dummyMonitorId
in thesettings.json
file. This way, the script doesn't attempt to restore monitor profiles that are already active.
Change Log
v1.2.0
- Hybrid GPU Script Support: Implements changes required for the Hybrid GPU Fix (https://github.com/Nonary/DuplicateOutputFailFix). Allowing those with laptops to always force NVIDIA Encoding, etc.
v1.1.9
- Updated MultiMonitorTool: Updated to v2.10.
- Primary Monitor Validation: Added a new option to increase the strictness of validation on restoring the primary monitor. This should reduce false positives for some users but may cause problems for others, so this option is not enabled by default.
v1.1.8
- Debug Logging: Added debug write statements across the app to facilitate easier troubleshooting of future issues.
- Monitor Flicker Fix: Resolved an issue causing the monitor to constantly flicker when applying the workaround mentioned in issue #9.
v1.1.7
- File Lock Fixes: Reduced the frequency of issues causing file lockouts during the parsing of monitor configurations.
- Improved Profile Restore: Enhanced the validation logic to ensure all monitor IDs match, reducing the occurrence of false positives.
v1.1.6
- Logging Fix: Fixed an issue where the log file wasn't created if a new stream started before the monitor was restored from the previous session.
- Code Update: Updated the script to use the SunshineScript Installer template, simplifying the maintenance of the installation process for all projects.
v1.2.0
README
This script automates the process of switching your primary monitor with a dummy monitor using MultiMonitorTool.
This is useful for users of Sunshine (a screen sharing software) who experience issues with sharing their primary monitor.
Caveats:
- If using Windows 11, you'll need to set the default terminal to Windows Console Host as there is currently a bug in Windows Terminal that prevents hidden consoles from working properly.
- That can be changed at Settings > System > For Developers > Terminal [Let Windows decide] >> (change to) >> Terminal [Windows Console Host]
- On older versions of Windows 11 it can be found at: Settings > Privacy & security > Security > For developers > Terminal [Let Windows decide] >> (change to) >> Terminal [Windows Console Host]
- The script will stop working if you move the folder, simply reinstall it to resolve that issue.
- Due to Windows API restrictions, this script does not work on cold reboots (hard crashes or shutdowns of your computer).
- If you're cold booting, simply sign into the computer using the "Desktop" app on Moonlight, then end the stream, then start it again.
- In the Sunshine WEB UI, make sure you leave the Output Name blank under the Audio/Video tab, otherwise it could cause breaking behavior with this script.
REQUIREMENTS
For GFE users
- This script no longer supports GFE, but you are able to retrieve a legacy version of this script that does support it: https://github.com/Nonary/MonitorSwapAutomation/releases/tag/legacy
For Sunshine users
- Version 0.19.1 or higher
- Host must be Windows
INSTRUCTIONS
-
Open up MultiMonitorTool and click on
File -> Save Monitors Configuration
and save it in the current folder this script is located in with the name ofprimary.cfg
. -
Repeat the same steps of step 1, except save it with the name of
dummy.cfg
. -
Open up the
dummy.cfg
file and set every parameter related to your primary monitor's position, refresh rate, etc. to0
. For example:Name=\\.\DISPLAY1 MonitorID=MONITOR\GSMC0C8\{4d36e96e-e325-11ce-bfc1-08002be10318}\0009 SerialNumber=LGTV BitsPerPixel=0 Width=0 Height=0 DisplayFlags=0 DisplayFrequency=0 DisplayOrientation=0 PositionX=0 Name=\\.\DISPLAY11 MonitorID=MONITOR\XMD29831\{4d36e96e-e325-11ce-bfc1-08002be10318}\0007 SerialNumber=DUMMY BitsPerPixel=32 Width=3840 Height=2160 DisplayFlags=0 DisplayFrequency=120 DisplayOrientation=0 PositionX=0
In the example above, every numerical value has been set to 0, which lets the script know that the display should be turned off.
Also take note in the example, that my dummy display should have values configured to let it know that it should be turned on. -
Verify that the
dummy.cfg
file has only one display that contains values for theBitsPerPixel
,Width
,Height
, and so on.
4a. For theprimary.cfg file
, it does not matter if there are other displays enabled, but you would want to make sure your dummy is "zeroed out" so you don't end up with an invisible monitor. -
Basically, primary will "zero out" the dummy plug, and dummy will "zero out" the main display. This will automatically transfer games and windows back to the primary monitor if setup this way.
-
In the
dummy.cfg
file, locate your dummyMonitorId
and copy and paste it to thedummyMonitorId
key in the settings.json file. Make sure to escape the backslashes. -
Validate you have escaped the backslashes, below is an example of a valid settings.json file.
{ "startDelay": 2, "gracePeriod": 60, "configSaveLocation": "%TEMP%", "dummyMonitorId": "MONITOR\\XMD009A\\{4d36e96e-e325-11ce-bfc1-08002be10318}\\0010" }
-
Install the script by double clicking the Install.bat file, you may get a smart-screen warning... this is normal.
-
You will be prompted for administrator rights, as modifying Sunshine configuration will require admin rights in the coming future.
-
If there are no error messages presented on the screen, the script successfully installed and you can close the terminal.
The paths referenced above will vary on your machine.
TROUBLESHOOTING
If you encounter issues with the script, you can try the following:
Monitor is not swapping before stream or afterwards
-
Check that your dummy monitor
MonitorId
matches the value in thedummyMonitorId
variable in thesettings.json
file. -
Check that you have escaped the backslashes for dummyMonitorId in the
settings.json
file.
Valid: MONITOR\\GSMC0C8\\{4d36e96e-e325-11ce-bfc1-08002be10318}\\0009Invalid: MONITOR\GSMC0C8{4d36e96e-e325-11ce-bfc1-08002be10318}\0009
-
Check that you have set every parameter related to the primary monitor's resolution in the
dummy.cfg
file to0
. -
Check that you have set every parameter related to the dummy monitor's resolution in the
primary.cfg
file to0
. -
Check that you have at least one monitor not "zeroed out" in both the primary.cfg and dummy.cfg files.
-
Ensure that you have followed the requirements for Sunshine users as listed above.
-
Increase the startDelay in the settings file if you're experiencing the script only works intermitently.
-
If you are still experiencing issues, try uninstalling and installing it again.
ResolutionAutomation script isn't changing my resolution after connecting and or is intermittently working
- First, ensure that MonitorSwapper is installed first, then install the ResolutionAutomation script.
- If you installed them out of order, uninstall both, then install MonitorSwapper, then ResolutionAutomation.
- Adjust the start delay in the settings.json file to 3 or 4 seconds and that should resolve that issue.
- Sometimes the swap can take longer to do and the resolution swap is happening on your primary screen
- Adjusting the start delay will give the swap more time to complete, thus making sure resolution is changed on the correct monitor.
Only One Screen is Being Restored, Everything Else Works
- You will have to follow the workaround mentioned here: MonitorSwapAutomation Issue #9
- There is currently a bug in the MultiMonitor tool affecting users with dual screens. I do not have the source code for that tool, so it is impossible for me to fix directly. A workaround is necessary until Nirsoft resolves this issue. Please report your issue to nirsofer@yahoo.com so he can gather more users and data to ultimately resolve this issue.
Primary Monitor Wasn't Restored
Check the logs to see if they claim the primary monitor was successfully restored. If it was, enable enableStrictRestoration
in the settings.json
file by setting it to true
. If the logs do not show it restored, it probably was closed out before the script could finish (in the case of reboots). In such cases, you can't do much to resolve it other than ensuring you do not reboot before returning to your machine.
Resolution Change When Resuming or Starting a New Stream
- Double-check and ensure you have put the correct
dummyMonitorId
in thesettings.json
file. This way, the script doesn't attempt to restore monitor profiles that are already active.
Change Log
v1.2.0
- Hybrid GPU Script Support: Implements changes required for the Hybrid GPU Fix (https://github.com/Nonary/DuplicateOutputFailFix). Allowing those with laptops to always force NVIDIA Encoding, etc.
v1.1.9
- Updated MultiMonitorTool: Updated to v2.10.
- Primary Monitor Validation: Added a new option to increase the strictness of validation on restoring the primary monitor. This should reduce false positives for some users but may cause problems for others, so this option is not enabled by default.
v1.1.8
- Debug Logging: Added debug write statements across the app to facilitate easier troubleshooting of future issues.
- Monitor Flicker Fix: Resolved an issue causing the monitor to constantly flicker when applying the workaround mentioned in issue #9.
v1.1.7
- File Lock Fixes: Reduced the frequency of issues causing file lockouts during the parsing of monitor configurations.
- Improved Profile Restore: Enhanced the validation logic to ensure all monitor IDs match, reducing the occurrence of false positives.
v1.1.6
- Logging Fix: Fixed an issue where the log file wasn't created if a new stream started before the monitor was restored from the previous session.
- Code Update: Updated the script to use the SunshineScript Installer template, simplifying the maintenance of the installation process for all projects.
v1.1.9
README
This script automates the process of switching your primary monitor with a dummy monitor using MultiMonitorTool.
This is useful for users of Sunshine (a screen sharing software) who experience issues with sharing their primary monitor.
Caveats:
- If using Windows 11, you'll need to set the default terminal to Windows Console Host as there is currently a bug in Windows Terminal that prevents hidden consoles from working properly.
- That can be changed at Settings > System > For Developers > Terminal [Let Windows decide] >> (change to) >> Terminal [Windows Console Host]
- On older versions of Windows 11 it can be found at: Settings > Privacy & security > Security > For developers > Terminal [Let Windows decide] >> (change to) >> Terminal [Windows Console Host]
- The script will stop working if you move the folder, simply reinstall it to resolve that issue.
- Due to Windows API restrictions, this script does not work on cold reboots (hard crashes or shutdowns of your computer).
- If you're cold booting, simply sign into the computer using the "Desktop" app on Moonlight, then end the stream, then start it again.
- In the Sunshine WEB UI, make sure you leave the Output Name blank under the Audio/Video tab, otherwise it could cause breaking behavior with this script.
REQUIREMENTS
For GFE users
- This script no longer supports GFE, but you are able to retrieve a legacy version of this script that does support it: https://github.com/Nonary/MonitorSwapAutomation/releases/tag/legacy
For Sunshine users
- Version 0.19.1 or higher
- Host must be Windows
INSTRUCTIONS
-
Open up MultiMonitorTool and click on
File -> Save Monitors Configuration
and save it in the current folder this script is located in with the name ofprimary.cfg
. -
Repeat the same steps of step 1, except save it with the name of
dummy.cfg
. -
Open up the
dummy.cfg
file and set every parameter related to your primary monitor's position, refresh rate, etc. to0
. For example:Name=\\.\DISPLAY1 MonitorID=MONITOR\GSMC0C8\{4d36e96e-e325-11ce-bfc1-08002be10318}\0009 SerialNumber=LGTV BitsPerPixel=0 Width=0 Height=0 DisplayFlags=0 DisplayFrequency=0 DisplayOrientation=0 PositionX=0 Name=\\.\DISPLAY11 MonitorID=MONITOR\XMD29831\{4d36e96e-e325-11ce-bfc1-08002be10318}\0007 SerialNumber=DUMMY BitsPerPixel=32 Width=3840 Height=2160 DisplayFlags=0 DisplayFrequency=120 DisplayOrientation=0 PositionX=0
In the example above, every numerical value has been set to 0, which lets the script know that the display should be turned off.
Also take note in the example, that my dummy display should have values configured to let it know that it should be turned on. -
Verify that the
dummy.cfg
file has only one display that contains values for theBitsPerPixel
,Width
,Height
, and so on.
4a. For theprimary.cfg file
, it does not matter if there are other displays enabled, but you would want to make sure your dummy is "zeroed out" so you don't end up with an invisible monitor. -
Basically, primary will "zero out" the dummy plug, and dummy will "zero out" the main display. This will automatically transfer games and windows back to the primary monitor if setup this way.
-
In the
dummy.cfg
file, locate your dummyMonitorId
and copy and paste it to thedummyMonitorId
key in the settings.json file. Make sure to escape the backslashes. -
Validate you have escaped the backslashes, below is an example of a valid settings.json file.
{ "startDelay": 2, "gracePeriod": 60, "configSaveLocation": "%TEMP%", "dummyMonitorId": "MONITOR\\XMD009A\\{4d36e96e-e325-11ce-bfc1-08002be10318}\\0010" }
-
Install the script by double clicking the Install.bat file, you may get a smart-screen warning... this is normal.
-
You will be prompted for administrator rights, as modifying Sunshine configuration will require admin rights in the coming future.
-
If there are no error messages presented on the screen, the script successfully installed and you can close the terminal.
The paths referenced above will vary on your machine.
TROUBLESHOOTING
If you encounter issues with the script, you can try the following:
Monitor is not swapping before stream or afterwards
-
Check that your dummy monitor
MonitorId
matches the value in thedummyMonitorId
variable in thesettings.json
file. -
Check that you have escaped the backslashes for dummyMonitorId in the
settings.json
file.
Valid: MONITOR\\GSMC0C8\\{4d36e96e-e325-11ce-bfc1-08002be10318}\\0009Invalid: MONITOR\GSMC0C8{4d36e96e-e325-11ce-bfc1-08002be10318}\0009
-
Check that you have set every parameter related to the primary monitor's resolution in the
dummy.cfg
file to0
. -
Check that you have set every parameter related to the dummy monitor's resolution in the
primary.cfg
file to0
. -
Check that you have at least one monitor not "zeroed out" in both the primary.cfg and dummy.cfg files.
-
Ensure that you have followed the requirements for Sunshine users as listed above.
-
Increase the startDelay in the settings file if you're experiencing the script only works intermitently.
-
If you are still experiencing issues, try uninstalling and installing it again.
ResolutionAutomation script isn't changing my resolution after connecting and or is intermittently working
- First, ensure that MonitorSwapper is installed first, then install the ResolutionAutomation script.
- If you installed them out of order, uninstall both, then install MonitorSwapper, then ResolutionAutomation.
- Adjust the start delay in the settings.json file to 3 or 4 seconds and that should resolve that issue.
- Sometimes the swap can take longer to do and the resolution swap is happening on your primary screen
- Adjusting the start delay will give the swap more time to complete, thus making sure resolution is changed on the correct monitor.
Only One Screen is Being Restored, Everything Else Works
- You will have to follow the workaround mentioned here: MonitorSwapAutomation Issue #9
- There is currently a bug in the MultiMonitor tool affecting users with dual screens. I do not have the source code for that tool, so it is impossible for me to fix directly. A workaround is necessary until Nirsoft resolves this issue. Please report your issue to nirsofer@yahoo.com so he can gather more users and data to ultimately resolve this issue.
Primary Monitor Wasn't Restored
Check the logs to see if they claim the primary monitor was successfully restored. If it was, enable enableStrictRestoration
in the settings.json
file by setting it to true
. If the logs do not show it restored, it probably was closed out before the script could finish (in the case of reboots). In such cases, you can't do much to resolve it other than ensuring you do not reboot before returning to your machine.
Resolution Change When Resuming or Starting a New Stream
- Double-check and ensure you have put the correct
dummyMonitorId
in thesettings.json
file. This way, the script doesn't attempt to restore monitor profiles that are already active.
Change Log
v1.1.9
- Updated MultiMonitorTool: Updated to v2.10.
- Primary Monitor Validation: Added a new option to increase the strictness of validation on restoring the primary monitor. This should reduce false positives for some users but may cause problems for others, so this option is not enabled by default.
v1.1.8
- Debug Logging: Added debug write statements across the app to facilitate easier troubleshooting of future issues.
- Monitor Flicker Fix: Resolved an issue causing the monitor to constantly flicker when applying the workaround mentioned in issue #9.
v1.1.7
- File Lock Fixes: Reduced the frequency of issues causing file lockouts during the parsing of monitor configurations.
- Improved Profile Restore: Enhanced the validation logic to ensure all monitor IDs match, reducing the occurrence of false positives.
v1.1.6
- Logging Fix: Fixed an issue where the log file wasn't created if a new stream started before the monitor was restored from the previous session.
- Code Update: Updated the script to use the SunshineScript Installer template, simplifying the maintenance of the installation process for all projects.
v1.1.8
README
This script automates the process of switching your primary monitor with a dummy monitor using MultiMonitorTool.
This is useful for users of Sunshine (a screen sharing software) who experience issues with sharing their primary monitor.
Caveats:
- If using Windows 11, you'll need to set the default terminal to Windows Console Host as there is currently a bug in Windows Terminal that prevents hidden consoles from working properly.
- That can be changed at Settings > System > For Developers > Terminal [Let Windows decide] >> (change to) >> Terminal [Windows Console Host]
- On older versions of Windows 11 it can be found at: Settings > Privacy & security > Security > For developers > Terminal [Let Windows decide] >> (change to) >> Terminal [Windows Console Host]
- The script will stop working if you move the folder, simply reinstall it to resolve that issue.
- Due to Windows API restrictions, this script does not work on cold reboots (hard crashes or shutdowns of your computer).
- If you're cold booting, simply sign into the computer using the "Desktop" app on Moonlight, then end the stream, then start it again.
- In the Sunshine WEB UI, make sure you leave the Output Name blank under the Audio/Video tab, otherwise it could cause breaking behavior with this script.
REQUIREMENTS
For GFE users
- This script no longer supports GFE, but you are able to retrieve a legacy version of this script that does support it: https://github.com/Nonary/MonitorSwapAutomation/releases/tag/legacy
For Sunshine users
- Version 0.19.1 or higher
- Host must be Windows
INSTRUCTIONS
-
Open up MultiMonitorTool and click on
File -> Save Monitors Configuration
and save it in the current folder this script is located in with the name ofprimary.cfg
. -
Repeat the same steps of step 1, except save it with the name of
dummy.cfg
. -
Open up the
dummy.cfg
file and set every parameter related to your primary monitor's position, refresh rate, etc. to0
. For example:Name=\\.\DISPLAY1 MonitorID=MONITOR\GSMC0C8\{4d36e96e-e325-11ce-bfc1-08002be10318}\0009 SerialNumber=LGTV BitsPerPixel=0 Width=0 Height=0 DisplayFlags=0 DisplayFrequency=0 DisplayOrientation=0 PositionX=0 Name=\\.\DISPLAY11 MonitorID=MONITOR\XMD29831\{4d36e96e-e325-11ce-bfc1-08002be10318}\0007 SerialNumber=DUMMY BitsPerPixel=32 Width=3840 Height=2160 DisplayFlags=0 DisplayFrequency=120 DisplayOrientation=0 PositionX=0
In the example above, every numerical value has been set to 0, which lets the script know that the display should be turned off.
Also take note in the example, that my dummy display should have values configured to let it know that it should be turned on. -
Verify that the
dummy.cfg
file has only one display that contains values for theBitsPerPixel
,Width
,Height
, and so on.
4a. For theprimary.cfg file
, it does not matter if there are other displays enabled, but you would want to make sure your dummy is "zeroed out" so you don't end up with an invisible monitor. -
Basically, primary will "zero out" the dummy plug, and dummy will "zero out" the main display. This will automatically transfer games and windows back to the primary monitor if setup this way.
-
In the
dummy.cfg
file, locate your dummyMonitorId
and copy and paste it to thedummyMonitorId
key in the settings.json file. Make sure to escape the backslashes. -
Validate you have escaped the backslashes, below is an example of a valid settings.json file.
{ "startDelay": 2, "gracePeriod": 60, "configSaveLocation": "%TEMP%", "dummyMonitorId": "MONITOR\\XMD009A\\{4d36e96e-e325-11ce-bfc1-08002be10318}\\0010" }
-
Install the script by double clicking the Install.bat file, you may get a smart-screen warning... this is normal.
-
You will be prompted for administrator rights, as modifying Sunshine configuration will require admin rights in the coming future.
-
If there are no error messages presented on the screen, the script successfully installed and you can close the terminal.
The paths referenced above will vary on your machine.
TROUBLESHOOTING
If you encounter issues with the script, you can try the following:
Monitor is not swapping before stream or afterwards
-
Check that your dummy monitor
MonitorId
matches the value in thedummyMonitorId
variable in thesettings.json
file. -
Check that you have escaped the backslashes for dummyMonitorId in the
settings.json
file.
Valid: MONITOR\\GSMC0C8\\{4d36e96e-e325-11ce-bfc1-08002be10318}\\0009Invalid: MONITOR\GSMC0C8{4d36e96e-e325-11ce-bfc1-08002be10318}\0009
-
Check that you have set every parameter related to the primary monitor's resolution in the
dummy.cfg
file to0
. -
Check that you have set every parameter related to the dummy monitor's resolution in the
primary.cfg
file to0
. -
Check that you have at least one monitor not "zeroed out" in both the primary.cfg and dummy.cfg files.
-
Ensure that you have followed the requirements for Sunshine users as listed above.
-
Increase the startDelay in the settings file if you're experiencing the script only works intermitently.
-
If you are still experiencing issues, try uninstalling and installing it again.
ResolutionAutomation script isn't changing my resolution after connecting and or is intermittently working
- First, ensure that MonitorSwapper is installed first, then install the ResolutionAutomation script.
- If you installed them out of order, uninstall both, then install MonitorSwapper, then ResolutionAutomation.
- Adjust the start delay in the settings.json file to 3 or 4 seconds and that should resolve that issue.
- Sometimes the swap can take longer to do and the resolution swap is happening on your primary screen
- Adjusting the start delay will give the swap more time to complete, thus making sure resolution is changed on the correct monitor.
Only one screen is being restored, everything else works
- You will have to do this workaround mentioned here: #9
- There is currently a bug in the MultiMonitor tool in some scenarios with people who have dual screens. I do not have the source code for that tool, so it is impossible for me to fix directly, a workaround has to be done until resolved by Nirsoft. Please report your issue to nirsofer@yahoo.com so he can gather more users and data to ultimately resolve this issue.
Resolution Change when resuming or starting new stream
- Double check and make sure you have put the correct "dummyMonitorId" in the settings.json file, that way the script doesn't attempt to restore monitor profiles that are already active.
Change Log
v1.1.8
- Debug Logging: Added debug write statements across the app to facilitate easier troubleshooting of future issues.
- Monitor Flicker Fix: Resolved an issue causing the monitor to constantly flicker when applying the workaround mentioned in issue #9.
v1.1.7
- File Lock Fixes: Reduced the frequency of issues causing file lockouts during the parsing of monitor configurations.
- Improved Profile Restore: Enhanced the validation logic to ensure all monitor IDs match, reducing the occurrence of false positives.
v1.1.6
- Logging Fix: Fixed an issue where the log file wasn't created if a new stream started before the monitor was restored from the previous session.
- Code Update: Updated the script to use the SunshineScript Installer template, simplifying the maintenance of the installation process for all projects.
v1.1.5
- Black Screen Issue Fix: Addressed an issue caused by a bug in the Windows Display API that could result in games streaming as a black screen or freezing after menu interactions.
- Code Cleanup: Refactored the script to improve performance and removed unnecessary code.
v1.1.4
- Monitor Restoration Fix: Corrected a premature script exit that occurred before the monitor could be restored, resolving issue #31.
v1.1.3
- Monitor Configuration Stability Fix: Solved a problem where monitor configurations could incorrectly change under specific conditions, such as when a stream was suspended and then resumed without completing the monitor restoration process from a previous session. This issue stemmed from an unexpected behavior in Windows' display settings API, which applied changes even when a monitor swap failed. The fix prevents the script from attempting to restore the primary monitor during streaming sessions, avoiding changes in host resolution.
v1.2.1
This script automates the process of switching your primary monitor with a dummy monitor using MultiMonitorTool.
This is useful for users of Sunshine (a screen sharing software) who experience issues with sharing their primary monitor.
Caveats:
- If using Windows 11, you'll need to set the default terminal to Windows Console Host as there is currently a bug in Windows Terminal that prevents hidden consoles from working properly.
- That can be changed at Settings > System > For Developers > Terminal [Let Windows decide] >> (change to) >> Terminal [Windows Console Host]
- On older versions of Windows 11 it can be found at: Settings > Privacy & security > Security > For developers > Terminal [Let Windows decide] >> (change to) >> Terminal [Windows Console Host]
- The script will stop working if you move the folder, simply reinstall it to resolve that issue.
- Due to Windows API restrictions, this script does not work on cold reboots (hard crashes or shutdowns of your computer).
- If you're cold booting, simply sign into the computer using the "Desktop" app on Moonlight, then end the stream, then start it again.
- In the Sunshine WEB UI, make sure you leave the Output Name blank under the Audio/Video tab, otherwise it could cause breaking behavior with this script.
REQUIREMENTS
For GFE users
- This script no longer supports GFE, but you are able to retrieve a legacy version of this script that does support it: https://github.com/Nonary/MonitorSwapAutomation/releases/tag/legacy
For Sunshine users
- Version 0.19.1 or higher
- Host must be Windows
INSTRUCTIONS
-
Open up MultiMonitorTool and click on
File -> Save Monitors Configuration
and save it in the current folder this script is located in with the name ofprimary.cfg
. -
Repeat the same steps of step 1, except save it with the name of
dummy.cfg
. -
Open up the
dummy.cfg
file and set every parameter related to your primary monitor's position, refresh rate, etc. to0
. For example:Name=\\.\DISPLAY1 MonitorID=MONITOR\GSMC0C8\{4d36e96e-e325-11ce-bfc1-08002be10318}\0009 SerialNumber=LGTV BitsPerPixel=0 Width=0 Height=0 DisplayFlags=0 DisplayFrequency=0 DisplayOrientation=0 PositionX=0 Name=\\.\DISPLAY11 MonitorID=MONITOR\XMD29831\{4d36e96e-e325-11ce-bfc1-08002be10318}\0007 SerialNumber=DUMMY BitsPerPixel=32 Width=3840 Height=2160 DisplayFlags=0 DisplayFrequency=120 DisplayOrientation=0 PositionX=0
In the example above, every numerical value has been set to 0, which lets the script know that the display should be turned off.
Also take note in the example, that my dummy display should have values configured to let it know that it should be turned on. -
Verify that the
dummy.cfg
file has only one display that contains values for theBitsPerPixel
,Width
,Height
, and so on.
4a. For theprimary.cfg file
, it does not matter if there are other displays enabled, but you would want to make sure your dummy is "zeroed out" so you don't end up with an invisible monitor. -
Basically, primary will "zero out" the dummy plug, and dummy will "zero out" the main display. This will automatically transfer games and windows back to the primary monitor if setup this way.
-
In the
dummy.cfg
file, locate your dummyMonitorId
and copy and paste it to thedummyMonitorId
key in the settings.json file. Make sure to escape the backslashes. -
Validate you have escaped the backslashes, below is an example of a valid settings.json file.
{ "startDelay": 2, "gracePeriod": 60, "configSaveLocation": "%TEMP%", "dummyMonitorId": "MONITOR\\XMD009A\\{4d36e96e-e325-11ce-bfc1-08002be10318}\\0010" }
-
Install the script by double clicking the Install.bat file, you may get a smart-screen warning... this is normal.
-
You will be prompted for administrator rights, as modifying Sunshine configuration will require admin rights in the coming future.
-
If there are no error messages presented on the screen, the script successfully installed and you can close the terminal.
The paths referenced above will vary on your machine.
TROUBLESHOOTING
If you encounter issues with the script, you can try the following:
Monitor is not swapping before stream or afterwards
-
Check that your dummy monitor
MonitorId
matches the value in thedummyMonitorId
variable in thesettings.json
file. -
Check that you have escaped the backslashes for dummyMonitorId in the
settings.json
file.
Valid: MONITOR\\GSMC0C8\\{4d36e96e-e325-11ce-bfc1-08002be10318}\\0009Invalid: MONITOR\GSMC0C8{4d36e96e-e325-11ce-bfc1-08002be10318}\0009
-
Check that you have set every parameter related to the primary monitor's resolution in the
dummy.cfg
file to0
. -
Check that you have set every parameter related to the dummy monitor's resolution in the
primary.cfg
file to0
. -
Check that you have at least one monitor not "zeroed out" in both the primary.cfg and dummy.cfg files.
-
Ensure that you have followed the requirements for Sunshine users as listed above.
-
Increase the startDelay in the settings file if you're experiencing the script only works intermitently.
-
If you are still experiencing issues, try uninstalling and installing it again.
ResolutionAutomation script isn't changing my resolution after connecting and or is intermittently working
- First, ensure that MonitorSwapper is installed first, then install the ResolutionAutomation script.
- If you installed them out of order, uninstall both, then install MonitorSwapper, then ResolutionAutomation.
- Adjust the start delay in the settings.json file to 3 or 4 seconds and that should resolve that issue.
- Sometimes the swap can take longer to do and the resolution swap is happening on your primary screen
- Adjusting the start delay will give the swap more time to complete, thus making sure resolution is changed on the correct monitor.
Only One Screen is Being Restored, Everything Else Works
- You will have to follow the workaround mentioned here: MonitorSwapAutomation Issue #9
- There is currently a bug in the MultiMonitor tool affecting users with dual screens. I do not have the source code for that tool, so it is impossible for me to fix directly. A workaround is necessary until Nirsoft resolves this issue. Please report your issue to nirsofer@yahoo.com so he can gather more users and data to ultimately resolve this issue.
Primary Monitor Wasn't Restored
Check the logs to see if they claim the primary monitor was successfully restored. If it was, enable enableStrictRestoration
in the settings.json
file by setting it to true
. If the logs do not show it restored, it probably was closed out before the script could finish (in the case of reboots). In such cases, you can't do much to resolve it other than ensuring you do not reboot before returning to your machine.
Resolution Change When Resuming or Starting a New Stream
- Double-check and ensure you have put the correct
dummyMonitorId
in thesettings.json
file. This way, the script doesn't attempt to restore monitor profiles that are already active.
Change Log
v1.2.1
- Updated MultiMonitorTool: Updated to v2.15, which fixes a lot of bugs that 22H4 windows users experienced mentioned in #49
v1.1.9
- Updated MultiMonitorTool: Updated to v2.10.
- Primary Monitor Validation: Added a new option to increase the strictness of validation on restoring the primary monitor. This should reduce false positives for some users but may cause problems for others, so this option is not enabled by default.
v1.1.8
- Debug Logging: Added debug write statements across the app to facilitate easier troubleshooting of future issues.
- Monitor Flicker Fix: Resolved an issue causing the monitor to constantly flicker when applying the workaround mentioned in issue #9.
v1.1.7
- File Lock Fixes: Reduced the frequency of issues causing file lockouts during the parsing of monitor configurations.
- Improved Profile Restore: Enhanced the validation logic to ensure all monitor IDs match, reducing the occurrence of false positives.
v1.1.6
- Logging Fix: Fixed an issue where the log file wasn't created if a new stream started before the monitor was restored from the previous session.
- Code Update: Updated the script to use the SunshineScript Installer template, simplifying the maintenance of the installation process for all projects.
v1.1.7
README
This script automates the process of switching your primary monitor with a dummy monitor using MultiMonitorTool.
This is useful for users of Sunshine (a screen sharing software) who experience issues with sharing their primary monitor.
Caveats:
- If using Windows 11, you'll need to set the default terminal to Windows Console Host as there is currently a bug in Windows Terminal that prevents hidden consoles from working properly.
- That can be changed at Settings > System > For Developers > Terminal [Let Windows decide] >> (change to) >> Terminal [Windows Console Host]
- On older versions of Windows 11 it can be found at: Settings > Privacy & security > Security > For developers > Terminal [Let Windows decide] >> (change to) >> Terminal [Windows Console Host]
- The script will stop working if you move the folder, simply reinstall it to resolve that issue.
- Due to Windows API restrictions, this script does not work on cold reboots (hard crashes or shutdowns of your computer).
- If you're cold booting, simply sign into the computer using the "Desktop" app on Moonlight, then end the stream, then start it again.
- In the Sunshine WEB UI, make sure you leave the Output Name blank under the Audio/Video tab, otherwise it could cause breaking behavior with this script.
REQUIREMENTS
For GFE users
- This script no longer supports GFE, but you are able to retrieve a legacy version of this script that does support it: https://github.com/Nonary/MonitorSwapAutomation/releases/tag/legacy
For Sunshine users
- Version 0.19.1 or higher
- Host must be Windows
INSTRUCTIONS
-
Open up MultiMonitorTool and click on
File -> Save Monitors Configuration
and save it in the current folder this script is located in with the name ofprimary.cfg
. -
Repeat the same steps of step 1, except save it with the name of
dummy.cfg
. -
Open up the
dummy.cfg
file and set every parameter related to your primary monitor's position, refresh rate, etc. to0
. For example:Name=\\.\DISPLAY1 MonitorID=MONITOR\GSMC0C8\{4d36e96e-e325-11ce-bfc1-08002be10318}\0009 SerialNumber=LGTV BitsPerPixel=0 Width=0 Height=0 DisplayFlags=0 DisplayFrequency=0 DisplayOrientation=0 PositionX=0 Name=\\.\DISPLAY11 MonitorID=MONITOR\XMD29831\{4d36e96e-e325-11ce-bfc1-08002be10318}\0007 SerialNumber=DUMMY BitsPerPixel=32 Width=3840 Height=2160 DisplayFlags=0 DisplayFrequency=120 DisplayOrientation=0 PositionX=0
In the example above, every numerical value has been set to 0, which lets the script know that the display should be turned off.
Also take note in the example, that my dummy display should have values configured to let it know that it should be turned on. -
Verify that the
dummy.cfg
file has only one display that contains values for theBitsPerPixel
,Width
,Height
, and so on.
4a. For theprimary.cfg file
, it does not matter if there are other displays enabled, but you would want to make sure your dummy is "zeroed out" so you don't end up with an invisible monitor. -
Basically, primary will "zero out" the dummy plug, and dummy will "zero out" the main display. This will automatically transfer games and windows back to the primary monitor if setup this way.
-
In the
dummy.cfg
file, locate your dummyMonitorId
and copy and paste it to thedummyMonitorId
key in the settings.json file. Make sure to escape the backslashes. -
Validate you have escaped the backslashes, below is an example of a valid settings.json file.
{ "startDelay": 2, "gracePeriod": 60, "configSaveLocation": "%TEMP%", "dummyMonitorId": "MONITOR\\XMD009A\\{4d36e96e-e325-11ce-bfc1-08002be10318}\\0010" }
-
Install the script by double clicking the Install.bat file, you may get a smart-screen warning... this is normal.
-
You will be prompted for administrator rights, as modifying Sunshine configuration will require admin rights in the coming future.
-
If there are no error messages presented on the screen, the script successfully installed and you can close the terminal.
The paths referenced above will vary on your machine.
TROUBLESHOOTING
If you encounter issues with the script, you can try the following:
Monitor is not swapping before stream or afterwards
-
Check that your dummy monitor
MonitorId
matches the value in thedummyMonitorId
variable in thesettings.json
file. -
Check that you have escaped the backslashes for dummyMonitorId in the
settings.json
file.
Valid: MONITOR\\GSMC0C8\\{4d36e96e-e325-11ce-bfc1-08002be10318}\\0009Invalid: MONITOR\GSMC0C8{4d36e96e-e325-11ce-bfc1-08002be10318}\0009
-
Check that you have set every parameter related to the primary monitor's resolution in the
dummy.cfg
file to0
. -
Check that you have set every parameter related to the dummy monitor's resolution in the
primary.cfg
file to0
. -
Check that you have at least one monitor not "zeroed out" in both the primary.cfg and dummy.cfg files.
-
Ensure that you have followed the requirements for Sunshine users as listed above.
-
Increase the startDelay in the settings file if you're experiencing the script only works intermitently.
-
If you are still experiencing issues, try uninstalling and installing it again.
ResolutionAutomation script isn't changing my resolution after connecting and or is intermittently working
- First, ensure that MonitorSwapper is installed first, then install the ResolutionAutomation script.
- If you installed them out of order, uninstall both, then install MonitorSwapper, then ResolutionAutomation.
- Adjust the start delay in the settings.json file to 3 or 4 seconds and that should resolve that issue.
- Sometimes the swap can take longer to do and the resolution swap is happening on your primary screen
- Adjusting the start delay will give the swap more time to complete, thus making sure resolution is changed on the correct monitor.
Only one screen is being restored, everything else works
- You will have to do this workaround mentioned here: #9
- There is currently a bug in the MultiMonitor tool in some scenarios with people who have dual screens. I do not have the source code for that tool, so it is impossible for me to fix directly, a workaround has to be done until resolved by Nirsoft. Please report your issue to nirsofer@yahoo.com so he can gather more users and data to ultimately resolve this issue.
Resolution Change when resuming or starting new stream
- Double check and make sure you have put the correct "dummyMonitorId" in the settings.json file, that way the script doesn't attempt to restore monitor profiles that are already active.
Change Log
v1.1.7
- File Lock Fixes: Reduced the frequency of issues that caused file lockouts during the parsing of monitor configurations.
- Improved Profile Restore: Enhanced the validation logic to ensure all monitor IDs match, thereby reducing the occurrence of false positives.
v1.1.6
- Logging Fix: Fixed an issue where the log file wasn't created if a new stream started before the monitor was restored from the previous session.
- Code Update: Updated the script to use the SunshineScript Installer template, simplifying the maintenance of the installation process for all projects.
v1.1.5
- Black Screen Issue Fix: Addressed an issue caused by a bug in the Windows Display API that could result in games streaming as a black screen or freezing after menu interactions.
- Code Cleanup: Refactored the script to improve performance and removed unnecessary code.
v1.1.4
- Monitor Restoration Fix: Corrected a premature script exit that occurred before the monitor could be restored, resolving issue #31.
v1.1.3
- Monitor Configuration Stability Fix: Solved a problem where monitor configurations could incorrectly change under specific conditions, such as when a stream was suspended and then resumed without completing the monitor restoration process from a previous session. This issue stemmed from an unexpected behavior in Windows' display settings API, which applied changes even when a monitor swap failed. The fix prevents the script from attempting to restore the primary monitor during streaming sessions, avoiding changes in host resolution.