MonSwitch


Multi Monitor support has finally reached Windows, with support in both Windows 98, Windows 2000 and Windows XP.  Great, I thought;  one cheap card and monitor later and I've got two displays up and running with nary a problem.  Productivity-wise I'd say it's the most useful addition to Windows for quite a while.

Now for the downside. It's all well and good running Developer Studio on one screen and your application in the other, no more redraw messages generated by the debugger, but there comes a time for something a little more relaxing.  In a word, games.   Basically there are quite a number of games that just don't like having two monitors. Even pretty clean games such as Starcraft get a bit confused when the mouse scrolls off screen 1 and over to screen 2, one inadvertent click later and the focus has changed and your game has minimized (or you could be running Sid Meyer's Alpha Centauri in which case you'll just be left hoping that it would minimize).  Either way, to be completely safe there are many games that probably want to be run in single monitor mode.   It didn't take long before I got fed up with right clicking on the desktop, editing the properties and then enabling or disabling the second monitor.  Hence MonSwitch.

MonSwitch is my first stab at a solution.  It is a command line tool that allows you to set the size, position, resolution and frequency of any or all of you monitors.   More, it'll save the current configuration to the registry, disable a monitor, and then reload the settings from the registry at a latter date, re-enabling the monitor.

The Files

MonSwitch is available in three forms.

As source code (200K), this zip contains all of the source in a VC 6 project.

A minimal zip (21K) just containing the binary, this assumes that you have the appropriate MFC DLLs on your system already.

A full zip (731K), the binary and all of the required DLLs.

MonSwitch is supplied as two files, MonSwitch.exe which actually does the work, and a JavaScript script, RunOnOneMonitor.js that serves as a sample as well as a handy wrapper for an application that wants to be run with a secondary monitor disabled. 

How to use MonSwitch

The simplest way to use MonSwitch is to configure the supplied JavaScript script and then run it with the command line of the application that you want run on one monitor.

At the top of the RunOnOneMonitor.js file there is a line:

var Secondary Monitor = "1";

Change this number to be the number of the monitor that you want disabled. If you are unsure what the number is then show the display properties, select the settings tab and then click the identify button. That should make it pretty clear.

Then you create a shortcut to your program that says something like this:

C:\bin\RunOnOneMonitor.js D:\Games\Starcraft\StarCraft.exe

That's it.  When you run this shortcut it'll switch off the selected monitor, run your program and then switch the monitor back on once you exit the application.  Try it with the command line "cmd /k prompt & exit" if you want to try it out easily.

MonSwitch Usage

MonSwitch takes quite a lot of command line parameters.  The simplest are:

Short Form

Long Form

Meaning

-m number

/Monitor number

Specify the monitor number

-e

/Enable

Enable the selected monitor

-d

/Disable

Disable the selected monitor

-s

/Save

Save monitor characteristics in the Registry

-l

/Load

Load monitor characteristics from a previously saved set in the Registry

The more complicated ones are:

Short Form

Long Form

Meaning

-h

/Height

Height of the display in pixels

-w

/Width

Width of the display in pixels

-f

/Frequency

Refresh frequency of the display

-b

/Bpp

Color depth as bits per pixel, e.g. 256 color is 8 bbp.

-x

/xPos

X position of the display, remember that if the display if to the left of your primary display then the x coordinate will be negative.

-y

/yPos

Y position of the display.

Warning.  Be careful setting the size and frequency of your display, stick to settings that you've tested out in the display properties control panel.   This tool has none of the "test for 5 seconds" checks that the GUI uses, so if you don't know exactly what works check it out with the GUI first.  My aim here wasn't to duplicate what the GUI already does perfectly well, but to add a neat tool that extends the existing functionality.  That said, the save and load should always be safe since it's going to start with settings that work, and then restore them.

License

Unfortunately there are unreasonable people out there so a  few things need to be spelt out.

This is all free, as such it's worth exactly what you paid for it.  I think that MonSwitch works well and will be more than happy to accept bug reports on it and fix them as and when time allows, but fundamentally if it's broken - then tough.  The source is here so you are welcome to fix it if you wish.  I accept no responsibility for any problems associated with the use or misuse of this software.

Contact Information

Please feel free to contact me with bugs, feature requests, enhancements or even just a "thanks I find this useful".  My email is guy@wyrdrune.com.

Last modified : Wednesday, May 24, 2000 20:10