Basically, I want to create a script that changes Windows (10) default playback device when I run the .ahk or compiled .exe. If it's my headphones (device 1 in soundcard analysis), it switches to my external speakers (device 6) and vice versa. I don't want it to trigger on a hotkey press - the exact 'problem' I have is that my current solution requires a hotkey press and I'd rather save as many physical keyboard and mouse inputs as I can for standardisation, instead I'd trigger the .ahk or .exe directly through a macro pad. I want the script to run it.
So far I've managed to grok this much:
Code: Select all
VA_SetDefaultEndpoint("playback:" (Toggle ? 1 : 6), 0)
Code: Select all
VA_SetDefaultEndpoint("playback:" (Toggle ? 6 : 1), 0)
I originally tried to bash something together to get the current default playback device name, store that as a variable and then use that variable to create an If statement ['if the current default device is headphones, then do this to switch it to speakers and vice versa'], but no luck. Best I could do was pilfer this to retrieve the device name:
Code: Select all
msgbox % va_getdevicename(va_getdevice("playback:1"))
Code: Select all
default := VA_GetDevice("playback:1")
MsgBox, %default%
I did find this script to have a key toggle between two devices:
Code: Select all
*ScrollLock::
Toggle := !Toggle
VA_SetDefaultEndpoint("playback:" (Toggle ? 1:6), 1)
VA_SetDefaultEndpoint("playback:" (Toggle ? 1:6), 2)
KeyWait ScrollLock
return
I must be overlooking something obvious on both paths; could I get a hand?