Say I want the hotkeys "Winkey + F1", "Winkey + F2" and "Winkey + F3" (so that you only need one hand) to switch between headphones, speakers and monitor audio output. I'd also like headphones to be default on startup.
The answer will be posted below!
If you haven't already, download AutoHotKey version 2 from here (exe) or here (zip).
Download and install NirCmd from here (x64) or here. Copy the path to nircmd.exe.
Create an .ahk file (e.g. ChangeAudioOutput_NirCmd.ahk) with the following content, while making sure that in the code at line 21 you change C:\your\path\to\nircmd.exe
to where you installed nircmd.exe:
#Requires AutoHotkey v2.0
; ======================================================================================================================
; Everything until the first `return` autoruns
; ======================================================================================================================
; Function definition. Changes Audio Output Device to `device`
; ======================================================================================================================
ChangeAudioOutput(device, show_msg_box:=true)
{
symbols := Map("Headphones", "🎧", "Speakers", "🔊", "Display", "🖥️") ; Python dict-like object, callable by `Val := Array[Key]`
if (show_msg_box)
symbol := symbols[device]
{
; Show a message box
MsgBox(
; MsgBox's message in the box
"Selected device: " symbols[device] device,
; MsgBox's title/heading
"Audio Output Device changed",
; time after which the MsgBox will close
"T0.3"
)
}
Run("C:\your\path\to\nircmd.exe setdefaultsounddevice " device) ; change device using nircmd
}
; set Headphones as default device for startup
ChangeAudioOutput("Headphones", false) ; false -> don't show message box at startup
return ; Everything above this `return` autoruns
; ======================================================================================================================
; ======================================================================================================================
; Audio Output Device Switch to Headphones/Speakers/Monitor
; ======================================================================================================================
; Audio Output Device Switch to Headphones
#F1:: ; Windows key + F1
{
ChangeAudioOutput("Headphones")
}
; Audio Output Device Switch to Speakers
#F2:: ; Windows key + F2
{
ChangeAudioOutput("Speakers")
}
; Audio Output Device Switch to Display/Monitor
#F3:: ; Windows key + F3
{
ChangeAudioOutput("Monitor")
}
Make sure your desired audio devices are called exactly "Headphones" and "Speakers" in the Sound Control Panel. To get there:
In order for this to work also after you restart your PC, do the following:
All done!