Yeah I am switching both the primary display device and primary audio device. I made two small programs to do this:
setdisplay
This will make the specified display device the primary one. It does not disable display devices (though it could)!
usage: setdisplay <target> | -l
<target> the display device to set as primary
-l lists all display devices
You need to provide the exact display adapter name. To find out what the names are you can use the -l switch. This is the output I get on my single screen desktop:
> setdisplay.exe -l
\\.\DISPLAY1, ATI Radeon HD 3200 Graphics
state : active, pruned, primary,
settings: 1920 x 1200 @ 59Hz - 32bpp
position: 0, 0
monitor : \\.\DISPLAY1\Monitor0, Generic PnP Monitor
\\.\DISPLAY2, ATI Radeon HD 3200 Graphics
\\.\DISPLAYV1, RDPDD Chained DD
state : mirroring,
\\.\DISPLAYV2, RDP Encoder Mirror Driver
state : mirroring,
\\.\DISPLAYV3, RDP Reflector Display Driver
state : mirroring,
All the mirroring devices are virtual ones and can be ignored. If I were to hook up a second screen it would be listed under \\.\DISPLAY2. So to make that screen primary I just call:
> setdisplay.exe "\\.\DISPLAY2"
setaudio
This is actually just a compiled AHK script that interacts with the Sound dialog (mmsys.cpl), as there is no windows API to change the default audio output device.
usage: setaudio <target>
<target> the audio device to set as default
You need to provide the (partial) name of the audio playback device as it is listed in the Sound dialog. So if I wanted to make the HDMI output the default device, I would call:
> setdisplay.exe "AMD HDMI Output"
Note that this script targets an English version of windows 7. Other languages will require a slight modification of the script, as it looks for specific strings.
Both programs are used by my launcher program. F.e.: before launching Steam, it will first switch to the TV by calling setdisplay and setaudio. When Steam is closed it will call setdisplay and setaudio again to switch back to the PC monitor in the arcade cabinet. I attached both programs, including source code. Both were compiled on 64-bit Win7, so I doubt they will work on other Windows version.