Releases: Nonary/MonitorSwapAutomation
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 [email protected] 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 [email protected] 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.
v1.1.6
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 [email protected] 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.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.1.5
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.
-
Verify that the sunshine.conf file is configured properly, if successful the global_prep_cmd should look like this
global_prep_cmd = [{"do":"powershell.exe -executionpolicy bypass -file "F:\sources\MonitorSwapAutomation\MonitorSwap-Dummy.ps1"","elevated":"false","undo":"powershell.exe -executionpolicy bypass -file "F:\sources\MonitorSwapAutomation\MonitorSwap-Functions.ps1" True"}]
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 [email protected] 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.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.1.4
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.
-
Verify that the sunshine.conf file is configured properly, if successful the global_prep_cmd should look like this
global_prep_cmd = [{"do":"powershell.exe -executionpolicy bypass -file "F:\sources\MonitorSwapAutomation\MonitorSwap-Dummy.ps1"","elevated":"false","undo":"powershell.exe -executionpolicy bypass -file "F:\sources\MonitorSwapAutomation\MonitorSwap-Functions.ps1" True"}]
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 [email protected] 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.
Recent Changes
- v1.1.3 - Resolved an issue where monitor configurations could incorrectly alter under certain conditions, such as when a stream was suspended and subsequently resumed, if the monitor restoration process from a previous session was not completed successfully. This was due to an unexpected behavior in Windows' display settings API, which applied changes even when a monitor swap failed. The fix ensures the script no longer attempts to restore the primary monitor if users are currently streaming, which would cause the host resolution to change.
- v1.1.4 - Fixed an issue that caused the script to prematurely exit before restoring the monitor (Fixes #31)
v1.1.3
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.
-
Verify that the sunshine.conf file is configured properly, if successful the global_prep_cmd should look like this
global_prep_cmd = [{"do":"powershell.exe -executionpolicy bypass -file "F:\sources\MonitorSwapAutomation\MonitorSwap-Dummy.ps1"","elevated":"false","undo":"powershell.exe -executionpolicy bypass -file "F:\sources\MonitorSwapAutomation\MonitorSwap-Functions.ps1" True"}]
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 [email protected] 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.
Recent Changes
- Resolved an issue where monitor configurations could incorrectly alter under certain conditions, such as when a stream was suspended and subsequently resumed, if the monitor restoration process from a previous session was not completed successfully. This was due to an unexpected behavior in Windows' display settings API, which applied changes even when a monitor swap failed. The fix ensures the script no longer attempts to restore the primary monitor if users are currently streaming, which would cause the host resolution to change.
v1.0.5
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.
-
Verify that the sunshine.conf file is configured properly, if successful the global_prep_cmd should look like this
global_prep_cmd = [{"do":"powershell.exe -executionpolicy bypass -file "F:\sources\MonitorSwapAutomation\MonitorSwap-Dummy.ps1"","elevated":"false","undo":"powershell.exe -executionpolicy bypass -file "F:\sources\MonitorSwapAutomation\MonitorSwap-Functions.ps1" True"}]
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 [email protected] so he can gather more users and data to ultimately resolve this issue.
Recent Changes
- Fixes a bug that prevented the script from restoring the display in some scenarios, if user left their Moonlight client at the host screen.
- Fixed a bug that prevented the script from self-terminating itself after the user suspended the session longer than their defined grace period in the settings file.
- Better multi-monitor support by validating that all screens have been restored instead of just the main primary one.
- Primary monitor id is no longer required in settings and has been removed, script will now automatically figure out the primary monitors identity.
1.0.4
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 > Privacy & security > Security > For developers > Terminal [Let Windows decide] >> (change to) >> Terminal [Windows Console Host]
- Prepcommands do not work from cold reboots, and will prevent Sunshine from working until you logon locally.
- You should add a new application (with any name you'd like) in the WebUI and leave both the command and detached command empty.
- When adding this new application, make sure global prep command option is disabled.
- That will serve as a fallback option when you have to remote into your computer from a cold start.
- Normal reboots issued from start menu, will still work without the workaround above as long as Settings > Accounts > Sign-in options and "Use my sign-in info to automatically finish setting up after an update" is enabled which is default in Windows 10 & 11.
- The script will stop working if you move the folder, simply reinstall it to resolve that issue.
- 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
- Sunshine must be installed as a service (it does not work with the zip version of Sunshine)
- Sunshine logging level must be set to Debug
- Users must have read permissions to
%WINDIR%/Temp/Sunshine.log
(do not change other permissions, just make sure Users have at least read permissions)
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
primary.cfg
file, locate your primaryMonitorId
and copy and paste it to theprimaryMonitorId
key in the settings.json file. Make sure to escape the backslashes. -
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%", "primaryMonitorId": "MONITOR\\GSMC0C8\\{4d36e96e-e325-11ce-bfc1-08002be10318}\\0009", "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.
-
Verify that the sunshine.conf file is configured properly, if successful the global_prep_cmd should look like this
global_prep_cmd = [{"do":"powershell.exe -executionpolicy bypass -file "F:\sources\MonitorSwapAutomation\MonitorSwap-Dummy.ps1"","elevated":"false","undo":"powershell.exe -executionpolicy bypass -file "F:\sources\MonitorSwapAutomation\MonitorSwap-Functions.ps1" True"}]
The paths referenced above will vary on your machine.
TROUBLESHOOTING
If you encounter issues with the script, you can try the following:
-
Check that your primary monitor
MonitorId
matches the value in theprimaryMonitorId
variable in thesettings.json
file. -
Check that your dummy monitor
MonitorId
matches the value in thedummyMonitorId
variable in thesettings.json
file. -
Check that you have escaped the backslashes in both the primaryMonitorId and 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.
Recent Changes
- Fixed a bug that caused the script to stall out Sunshine that could not be recovered until restarting the service.
Dummy Plug Automation Script
Superseded by https://github.com/Nonary/MonitorSwapAutomation/releases/latest
Please visit the link above to download the latest version of the script.
LEGACY - GFE Users and Older Sunshine Versions Release
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 streaming their primary monitor or in cases they want to keep their main monitor off.
CAVEATS
- If you are using Windows 11, you need to set your default terminal to "Windows Console Host". Windows Terminal is currently bugged and does not respect hiding PowerShell scripts.
- Once you install this script, you cannot move this folder as it will break the automation. If you need to move the folder, simply uninstall and install the script again.
REQUIREMENTS
For GFE users
- None
For Sunshine users
- Host must be Windows
- Sunshine must be installed as a service (it does not work with the zip version of Sunshine)
- Sunshine logging level must be set to Debug
- Users must have read permissions to
%WINDIR%/Temp/Sunshine.log
(do not change other permissions, just make sure Users have at least read permissions)
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 in both
primary.cfg
anddummy.cfg
that only one display contains values for theBitsPerPixel
,Width
,Height
, and so on. -
Basically, primary will "zero out" the dummy plug, and dummy will "zero out" the main display. The reason is so that the windows transfer back automatically to the other screen when swapping profiles.
-
In the
MonitorSwap-Dummy.ps1
file, locate your primaryMonitorId
and copy and paste it to theprimaryMonitorId
variable. For example:$primaryMonitorId = "MONITOR\GSMC0C8\{4d36e96e-e325-11ce-bfc1-08002be10318}\0009"
-
Install the script by double-clicking the
Install Script.bat
file.
TROUBLESHOOTING
If you encounter issues with the script, you can try the following:
- Check that your primary monitor
MonitorId
matches the value in theprimaryMonitorId
variable in theMonitorSwap-Dummy.ps1
file. - 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.
- If you are still experiencing issues, try uninstalling and reinstalling the script.