Skip to content

Instantly share code, notes, and snippets.

@stecman
Last active September 18, 2020 03:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stecman/91cbdd7243d223ee1201af9bf563c016 to your computer and use it in GitHub Desktop.
Save stecman/91cbdd7243d223ee1201af9bf563c016 to your computer and use it in GitHub Desktop.
AutoHotKey script to toggle audio output device in Asus Xonar Essence STX control panel
; Switch output between headphones and speakers in Asus Xonar STX Control Panel
; On Linux can be done through easily through the ALSA command line tools, but on Windows it's GUI all the way down
;
; This assumes the Xonar Essence STX Audio Center is already running
SetTitleMatchMode, 3 ; Exact match
DetectHiddenWindows, On
ControlWindowTitle := "Xonar Essence STX Audio Center"
GoToMainTab()
{
ControlClick, Button8
}
; Toggle control panel window visibility (Win+F10)
; This saves digging through the task tray to open it if needed
#F10::
IfWinExist, %ControlWindowTitle%
{
if WinActive() {
WinClose
} else {
WinRestore
WinActivate
}
}
return
; Switch output to headphones (Win+F11)
#F11::
IfWinExist, %ControlWindowTitle%
{
WinRestore
WinActivate
GoToMainTab()
; Switch output if needed
ControlGet, selected_output, Choice, , ComboBox5
if (selected_output = "2 Speakers") {
Control, ChooseString, Headphone, ComboBox5
SoundSet, 50 ; My headphones have an inline volume control, so boost the volume after switching
TrayTip, Headphones, Switched sound output to Headphones
} else {
TrayTip, Headphones, Already set to headphones
}
WinClose
}
return
; Switch output to speakers (Win+F12)
#F12::
IfWinExist, %ControlWindowTitle%
{
WinRestore
WinActivate
GoToMainTab()
; Switch output if needed
ControlGet, selected_output, Choice, , ComboBox5
if (selected_output = "2 Speakers") {
TrayTip, Speakers, Already set to speakers
} else {
SoundSet, 10 ; My speakers are really loud, so go to a sane volume level first
Control, ChooseString, 2 Speakers, ComboBox5
TrayTip, Speakers, Switched sound output to Speakers
}
WinClose
}
return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment