Blog Archives

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

Posted in autoit Tagged with: , , , ,
  • admin-photo
  •  
  • brandon fiquett
  • tech enthusiast, developer, engineer, scuba instructor, drone pilot, K2FIQ.

subscribe via email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 4 other subscribers