Many people have a TV connected to their computer via HDMI as their secondary monitor. It is very convenient for HTPC usages, but playing games on the TV can be nice as well (especially when you have a gamepad connected).
The trouble is, most games will only run on the primary monitor, and the only way to get them to run on the TV is to make it the primary monitor. Windows makes this rather easy, but still, doing it manually each and every time before playing can be cumbersome. Fortunately, Michael Welter comes to the rescue with W7ToggleDisplay, a simple command-line tool that does the switching (don’t worry about the name, it works on Windows 8.1 as well). Simply run w7toggledisplay.exe /primary to make the switch.
Another annoyance is in the audio department. Presumably, when you play a game on the TV, you want the audio to come out of it as well (be it through its speakers or through some audio system connected to it). Since HDMI can carry audio, the easiest thing to do is switch the default playback device to the HDMI audio device. Again, this is easy enough to do but a nuisance to do every time. Fortunately, Dave Amenta created AudioEndPointController, a command-line tool that switches playback devices (even though the post mentions Windows 7, I’ve used it on Windows 8.1 without a hitch). First run EndPointController.exe and note the number identifiers for your regular and HDMI audio devices (the X in Audio Device X:). Then Run EndPointController.exe X where X is the number of the device you want to switch to.
Putting it all together
Now that we have all the prerequisites, we can create the following batch file to switch primary monitors, switch to HDMI audio output, run the game, and finally when the game is over switch everything back:
Where X is the ID of your HDMI audio device, Y is the ID of your regular audio device, and Game.exe is the executable of your game.
Unfortunately, the above won’t work for Steam games, since they are not launched directly via their executable. Instead, they are launched via a special protocol that looks like steam://rungameid/219150. You can replace Game.exe above with start steam://rungameid/X where X is the steam ID of your game (as it appears in the original shortcut). This will launch the game, but the trouble is it won’t wait for the game to quit, switching the audio and display immediately back (the /wait switch doesn’t help). I haven’t found a way around that (if anyone is aware of one I’d be happy to hear), so for Steam games I use two batch files. One to switch primary display and audio, and run the game:
And then another script to toggle everything back (I give it a shortcut so I don’t have to find the icon on the TV every time):
Happy gaming !