AutoIt Script – Toggle your HTPC sound output (Win7)

Wrote a little script to toggle the sound output for my HTPC and announce the current output. Once the script is compiled (or not), you can assign it to a Windows hot-key and map to your media remote or call it by some other means (use your imagination). Requires AutoIT unless compiled to an exe using the AutoIT compiler.

TraySetState (4)
Global $o_speech = ObjCreate("SAPI.SpVoice")
ToggleSoundOutput()
Func ToggleSoundOutput()
Run("control.exe mmsys.cpl")
WinWaitActive("Sound")
ControlSend("Sound","","","{DOWN}")
If ControlCommand("Sound","","&Set Default", "IsEnabled") Then
TrayTip("Sound Output: TV"," ",10,1)
ControlClick("Sound","","&Set Default")
ControlClick("Sound","","OK")
$o_speech.Speak("Sound switched to TV")
Else
TrayTip("Sound Output: AMP"," ",10,1)
ControlSend("Sound","","","{DOWN}")
ControlClick("Sound","","&Set Default")
ControlClick("Sound","","OK")
$o_speech.Speak("Sound switched to AMP")
EndIf
EndFunc
Exit

2 thoughts on “AutoIt Script – Toggle your HTPC sound output (Win7)

  1. Hi,

    With your script, I have made one to switch between my 3 audio outputs (Header, Second screen and hifi).

    Thank you.

Leave a Reply