Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

share|improve this question

2 Answers 2

up vote 6 down vote accepted

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.

USAGE
  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.

OPTIONS
  -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 ]

share|improve this answer

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:

http://stackoverflow.com/a/2216886/265706

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

share|improve this answer
    
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. –  Tanner Nov 2 '12 at 22:19

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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