I want to easily switch between speakers and headphones. Is this possible?


There are ways to switch the default audio device. However, because there is no published API for this, the techniques mostly involve hacks like trying to send keys, which is not very robust.

The API is kept closed and undocumented to avoid hardware incompatibilities so that manufacturers don't fight over it like the default home page on a browser. However, somebody has managed to switch audio devices on the command line in Windows 7, and in the comments WarNov has already "tested it in Windows 8. Works perfectly".

Remember that it is using an undocumented API, so may break in future versions of Windows.

As already mentioned by Jerry, you can create shortcuts with tiles, just make it call the C++ code. If you want to use it in .NET, you can also use a wrapper.

The code is also published on GitHub as AudioEndPointController, with easy to understand documentation on how to use it:

> EndPointController.exe --help
Lists active audio end-point playback devices or sets default audio end-point
playback device.

  EndPointController.exe [-a] [-f format_str]  Lists audio end-point playback
                                               devices that are enabled.
  EndPointController.exe device_index          Sets the default playback device
                                               with the given index.

  -a             Display all devices, rather than just active devices.
  -f format_str  Outputs the details of each device using the given format
                 string. If this parameter is ommitted the format string
                 defaults to: "Audio Device %d: %ws"

                 Parameters that are passed to the 'printf' function are
                 ordered as follows:
                   - Device index (int)
                   - Device friendly name (wstring)
                   - Device state (int)
                   - Device default? (1 for true 0 for false as int)
                   - Device description (wstring)
                   - Device interface friendly name (wstring)
                   - Device ID (wstring)''

It is also wrapped with PlaybackDevice [ Audio Output Switch ]

  • As of May 2016 can report that the code for AudioEndPointController is functional in Windows 10. That and two batch files provide one click short cuts to change the default audio output. – jdr5ca May 17 '16 at 6:57

Well, a tile can be a shortcut to a batch file or a PowerShell file. Tapping the tile will execute the batch or PS file. That means you can create a tile to do JUST ABOUT anything in Windows.

Here's the CS technique:


The answer NOT marked as answer appears to be the solution for Windows 7/8.

This might be as good as it gets for this particular API, I am sorry to say.

Here's the shortcut technique: http://www.howtogeek.com/74331/how-to-create-your-own-windows-8-shortcuts-for-shutdown-perhaps/

Oh by the way, Windows RT devices have PowerShell, too

  • The problem being there isn't an API to programmatically switch the default audio device... At least there wasn't in Windows 7, doubtful for Windows 8. – rtf Nov 2 '12 at 22:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.