Windows 7 Tip: How to change the default audio device with a hotkey
Windows Vista and 7 have a new audio subsystem, with lots of neat features. It is not, however, without its quirks. One such quirk is the inability to automatically change the default audio device; you must do it manually.
This means that if you have both headphones and speakers plugged into your computer, whenever you want to pipe all sound through the headphones you must right-click the volume icon, select Playback devices, go to the device you wish to set as default, right-click it, and select Set as Default Device. Sounds like fun, right? Now try doing this 5-6 times a day.
Incredibly enough, I could find no command-line utilities to automate this simple operation. I thought I might build something myself, so I started digging deeper. It turns out Microsoft seems to have done this by design; they wanted to prevent programs from changing the default audio device on users, because this can lead to a very bad experience (imagine a game which suddenly changes the audio to the speakers, when you wanted to listen to it using your earbuds).
I did try a couple of utilities which claimed to do this, but they were really bad. At this point, I did what I do every time the going gets rough: I turned to AutoHotkey. This amazing free automation program has a solution for just about anything, and indeed, AHK user Veabers already created the exact script I wanted in 14 elegant lines of code. This script toggles between two audio devices in about half a second on my system. Just hit Win+Shift+A, and you switch to the other device. Here's the whole thing:
#+a::
Run, mmsys.cpl
WinWait,Sound
ControlSend,SysListView321,{Down}
ControlGet, isEnabled, Enabled,,&Set Default
if(!isEnabled)
{
ControlSend,SysListView321,{Down 2}
}
ControlClick,&Set Default
ControlClick,OK
WinWaitClose
SoundPlay, *-1
return
Voila! The only thing I changed was the default key-binding, because the author's default did not work for me.














Comments
9
Subscribe to commentsrl78Jun 16th 2010 8:05AM
..."they wanted to prevent programs from changing the default audio device on users, because this can lead to a very bad experience (imagine a game which suddenly changes the audio to the speakers, when you wanted to listen to it using your earbuds)."
LMAO...come on man, you know your talking about having your porn being broadcast without your consent, not your games. Hehehe
grobbioJun 16th 2010 8:29AM
AutoHotKy and that script just made my day. Huge thank you.
TaomynJun 16th 2010 8:34AM
Yes, thanks for this. Had to change the "Down 2" to "Down 1" on my system as my devices seem to be set up differently, but it works a treat.
joulesbeefJun 16th 2010 10:40AM
Do you have realtek sound?
in the control panel should be a realtek icon. If not and you are sure you have the realtek chip, just install the latest drives and make sure it isnt the "drivers only" package.
In the top right is a link "device advanced settings"
there should be a check box.. mute back connections when front head phones are plugged in.
works great.. if not use this posted script and thanks for making it
spatimouth01Jun 17th 2010 12:15AM
Thank you times 100!!!
Big BenJun 16th 2010 4:12PM
While I do have two audio devices on my main computer, I have the on-board completely cut out of the loop in favor of a higher quality card connected to an external Mackie control board. Who needs a hotkey on your desktop when you can hit a button on the board and cut the studio monitors out of the loop. If I recall there have even been more consumer / game oriented products on the market that had similar functionality, such as the Microsoft sidewinder game voice. Wow, how is it that I can remember the names of defunct technologies better than I can remember the name of the girl from the bar last night?
HarshAug 15th 2010 6:11AM
I forgot how awesome AutoHotkey can be.
PuzzleballJun 17th 2010 3:22AM
I have another problem where for some reason my ATI HDMI sound output is not enabled by default if my TV is not turned on when the computer boots. I have to turn my TV on, then unplug and re-plug in the HDMI cable to enable the device so I can even select it. Does anyone know if there is a way to allow a "disconnected" device to be selected?
Alex ShuAug 21st 2010 10:07AM
You are supreme !!! just what I need for my HTPC :D