Quicker way to swap microphones & speakers in Windows 7?

9,093

Solution 1

Nircmd's setdefaultsounddevice command should help you:

nircmd setdefaultsounddevice [Device Name] {Role}

Set the default sound device on Windows 7/Vista/2008. The [Device Name] is the name of the device, as it appears in the sound devices list of Windows, for example: Speakers, Line In, Microphone, and so on...

The {Role} parameter is optional and may countain one of the following values: 0 for Console (the default value), 1 for Multimedia, and 2 for Communications.

Examples:

setdefaultsounddevice "Line In"
setdefaultsounddevice "Microphone" 2

You can easily create a shortcut for this manually or using either cmdshortcut or cmdshortcutkey.

This AutoHotkey forum thread also contains scripts that you might find useful.

Finally, Set Sound Device is a compiled AutoIt script that helps you do the same thing:

SSD enables you to change the default Sound Device for Win7 (works maybe for Vista too, but this is untested) via the commandline. To call SSD from the commandline, the syntax is ‘SSD.exe #’ (where # is the number of the Sound Device to select from the list,’Select Default’ dropdown box must be enabled to make device selectable).

1

Solution 2

Use AutoIt and compile your own .EXE to automate the swap process.
Bind a shortcut to that .EXE for more comfort.

This script does exactly the same as you do when you manually swap your devices but only with the your keyboard instead of a mouse.

How to use

  1. Download & extract the AutoIt Self Extracting Archive
  2. Copy & Paste this code to a new text file

    Run("c:\windows\system32\control.exe mmsys.cpl")
    WinWaitActive("Sound")
    WinSetOnTop ("Sound","Sound", 1 )
    
    ;Toggle between sound device 1 and 2
    send("{DOWN}")
    if ControlCommand("Sound", "", 1002, 'IsEnabled') Then
        ControlClick("Sound", "Set Default", 1002)
        $message = "Headset 1"
    else
        send("{DOWN}")
        ControlClick("Sound", "Set Default", 1002)
        $message = "Headset 2"
    EndIf
    
    ;Toggle between microphone device 1 and 2
    Send("{TAB 5}")
    Send("{RIGHT}")
    send("{DOWN}")
    if ControlCommand("Sound", "", 1002, 'IsEnabled') Then
        ControlClick("Sound", "Set Default", 1002)
    else
        send("{DOWN}")
        ControlClick("Sound", "Set Default", 1002)   
    EndIf
    
    WinClose("Sound")
    TrayTip("", $message, 5)
    Sleep(2000)
    
  3. Save it as deviceswapper.au3
  4. Open AutoIt\install\Aut2Exe\Aut2exe.exe and convert your .AU3 file to a .EXE
  5. Create a shortcut to that .EXE and set up a suitable shortcut key

Note: On localized Windows versions (German, Spanish, French etc.),
you have to replace the string Set Default with your localized button text.

Here you can read more about all used commands.

Share:
9,093

Related videos on Youtube

David Ross
Author by

David Ross

Pacific Northwest software developer with interests in Python/JS/WebDev, craft beer, cooking, and intersectional support. https://keybase.io/crystaldave

Updated on September 18, 2022

Comments

  • David Ross
    David Ross over 1 year

    I have a headset with a built-in microphone, and a set of speakers with a Blue Yeti microphone, all connected to a Windows 7 PC.

    I'd like to be able to switch between the headset mic/speakers and the Yeti mic & speakers without having to go into the Sound options and manually swap out the default audio device and default communications device.

    I've Googled for software to do this, but haven't found any results that work for microphones/recording devices. Is there software that'll do this, or is this something I'll have to look into writing for myself?

  • nixda
    nixda almost 11 years
    You may have to alter the code if you have more than 2 devices in your sound or microphone list. Let me know if this is the case.