Audio device switcher for Windows 7

bdr529

Limp Gawd
Joined
Nov 9, 2001
Messages
500
I made a program for Windows 7 to make it easier to switch between audio output devices and thought I would share. It really bugged me that you needed so many clicks to change audio devices.

My goal was to make it look like the Windows 7 flyout widget programs like when you click the volume icon. When you open the program it will add an icon to your system tray that when clicked will list your audio device. Click on a device and it will be changed to your preferred playback device. I am pretty new to C#, but it works on the few people i shared it with. If you open it in anything but Windows 7 it will crash because I am using a new Windows 7 API to get the system tray icon location and I am too lazy to make a warning popup.

Nk2P0.jpg


You can download it here

If anyone has a better hosting site let me know, never really had to host a zip file before.

Credit goes to this guy for figuring out the undocumented API for setting prefered audio devices http://www.daveamenta.com/2011-05/p...e-default-sound-playback-device-in-windows-7/. I just made it into a DLL and gave it a pretty front end.
 
SUGGESTION: I run 7.1 analog from my X-Fi soundcard to my receiver. I like to run with my speakers set as "full-range" speakers so that games and media players can redirect low frequencies without other stuff being unnecessarily redirected, however, some games don't at all send low frequencies to the subwoofer (SHAME ON YOU OPENAL) so I have to go in and uncheck these settings so that Windows will work with my Creative crap and redirect bass to the subwoofer for the slacker games.

XfzXL.png


I could find use in your program if you could make it toggle these settings.
 
Yeah, I have no idea how to do that :p, but thanks for the suggestion. This is just a solution to a problem I had after buying a USB headset. At first I used some AutoIt script to change the devices by a mouse macro but eventually found this guys blog with a programmatic way. I am not sure what you want may even be possible. MS was pretty sneaky hiding the API to change the preferred device, don't know if they expose that stuff.
 
Interesting, thanks for sharing, an app like that but to change the playback setting from speakers to headphones would be cool but like you said, not sure if it's possible at all.
 
What is this written in? Are you willing to share the source?

The DLL is written in C++ and is responsible for retrieving the audio device list and setting the preferred device. The main program is a simple C# app that is just a window and a list box with a bunch of tweaks to make it look and behave like the windows flyouts. I might be willing to share it later, but the code isn't really presentable now.
 
Awesome, thanks. I have headphones and speakers on different sound cards so this is what I need.
 
Thanks so much for this. I was looking for something just like this and I kept stumbling across some bloated apps that I was afraid to even touch. Thanks for keeping it simple and clean!
 
The DLL is written in C++ and is responsible for retrieving the audio device list and setting the preferred device. The main program is a simple C# app that is just a window and a list box with a bunch of tweaks to make it look and behave like the windows flyouts. I might be willing to share it later, but the code isn't really presentable now.

I'd also be interested in seeing the source if you ever publish it :cool:
 
Thanks for this, i was looking for something similar. :)

I would suggest adding custom shortcut key support (ie: ctrl + alt + "key", or alt + "key", or just "key"), for switching between available audio devices. Or maybe just left clicking on the icon would automatically switch, without showing the menu; right click on icon for menu.

And make the icon white, just the like the default win7 volume icon. :p

Anyway, thanks again.
 
I too am eagerly waiting to see the source if you post it. I've been wanting to make this exact tool myself but couldn't figure out how. My dream is to do almost exactly as you did, though to ultimately extend the built-in volume control app instead of having a separate tool just for this (failing that, a separate app that also controls the volume)
 
Neat little program. Fortunately for me since I use a USB soundcard to hook to my headset, and onboard audio for my desktop speakers, I just unplug my USB soundcard when I don't need the headphones. It's easy to do since I use one of my front USB ports to connect the external card. Windows switches automatically from the USB soundcard to the onboard because it's the only sound device in the system. When I plug the USB stick back in, it becomes the output device since it is the default sound device.
 
Good idea. I can't seem to get it to do anything though. After running the exe, I click on the tray icon (smart making it distinctive from the default Windows one BTW) and nothing happens. I really want this to work since my HDMI audio routinely drops and isn't restored to default when it comes back and I'd like a quick two click restore of the default. Is there anything that I'm missing?
 
Dude thanks so much!

I use analog audio from my onboard to a equalizer then to my receiver for my headphones (since my receiver equalizer doesn't work for the headphone output) and HDMI from my video card to my receiver for 5.1 in movies and games.

Having said that I love that you made this because I frequently switch from onboard (night listening or music) to HDMI (movies and games)...I actually looked on this thread thinking the title was a question and was looking forward to peoples suggestions when lo and behold the answer to my problems was in the first post! :-D

Thanks OP! Any PayPal for donations?!
 
Agreed, I would definitely donate. Great app, and it's shameful that this feature isn't built into Win7.
 
WTB app for Xonar cpanel that lets you bind a keyboard shortcut to different headphone and speaker "profiles."
 
Hey, I was wondering if you could add a feature to reroute audio just like "velbac" did to reroute x-fi audio through hdmi. While switching. I would donate.
 
This is awesome, however, in higher resolutions if used with larger icons/fonts, it's display is a little broken(cuts off choices due to padding I'm guessing).

Works like a charm though! Thanks a lot!
 
Awesome, always thought the output switching rigmarole was the worst thing about Win7.
 
Hi,

Registered just to say thanks. Also the program's pop out menu is messed up (cut off) on bigger DPI setting on Windows. Any way to fix it?
 
thanks for this!

put in my start up folder and now can easily switch between USB speakers and headphones.
 
Last edited:
Switch Between Sound Outputs with a Keyboard Shortcut (with AutoHotkey):

Just discovered a short autohotkey script to switch playback devices on Win 7. So I can switch from headphones to externals with a single button press. Just paste this into your AutoHotkey script:

^!s::
Run, mmsys.cpl
WinWait,Sound
ControlSend,SysListView321,{Down 2}
ControlClick,&Set Default
ControlClick,OK
return

Obviously you can change the keyboard shortcut to whatever you want; this one is Ctrl+Alt+S. This activates the 2nd device in the Sound window's list; in the above case, the speakers. Just change the number in {Down 2} to match the one you want to enable. You can then create two shortcuts, one for your speakers and one for your USB headphones or DAC.

This is not my writing and i haven't tested it yet, i've just found it on lifehacker.
 
You're my favorite person ever. I contemplated writing a program to do exactly this for exactly the same reasons.

Works in Windows 8, btw.
 
Great job. I've been looking for something like this for years.

Any chance you could get this to work with creative's auto switcher?
Or reproduce the functionality?

It changes settings on the fly depending on the .exe that is running.
So you could have it change to settings to Gaming USB when launching BF2 and then switch to Entertainment Toslink when launching VLC, for example.
 
Tested the program on a 64-bit machine but nothing pops up. I can see it was compiled as 32-bit. Any chance it could be recompiled from "AnyCPU" to "X86" in the advanced compiler options so it could work on either 32 or 64 bit? * Never mind * my own stupidity, it works fine in 64 bit.
 
Last edited:
Glad to see you've got it working. I've stopped using it because at 1920 x 1200, I can't click on the last audio device and that is the one that I need to switch to/from all of the time. Great free app, but not very useful for me if I can't click on what I need to easily.
 
Just want to bump this to the top. I love this program, lost it a while ago, but just re-installed it.
 
This is just superb, and ever so much appreciated. I have two W7 machines, one with three sources, the other with two, that I'm swapping between *all*the*time* and this app is a lifesaver.
Can I award double kudos? :)
Seriously, you should market that, bdr529!! Or at least point us to a PayPal button - I'd sling you some moola for that for sure....
 
Back
Top