So the goal of what I'm trying to accomplish is relatively simple in theory, but I may not be going about this with the correct method. I play Playerunknown's Battlegrounds (game for those of you who don't know it) which requires me to change my default audio device on Win 7 to my headphones everytime I want to play. It's a pain in the ass. So I figured I could just automate this with Autohotkey. All I've seen for the most part are hotkey scripts. I'm looking for a shortcut related script.
For instance:
Start PUBG from desktop shortcut
AHK script runs - changes default sound to headphones via batch file
Once I exit PUBG - changes default sound back to my Amp via batch file
Simple as that. So to do this I've opted to use Nircmd so I don't have to see the sound window popup and such. So far this is what I've got..
Code: Select all
#Persistent
WinWaitActive, PLAYERUNKNOWN'S BATTLEGROUNDS
Sleep, 100
Run, headphones.cmd (first batch file here)
WinActivate, PLAYERUNKNOWN'S BATTLEGROUNDS
Sleep, 100
Process, Exist, TslGame.exe
Variable= ErrorLevel
If Variable= 0
WinActivate, PLAYERUNKNOWN'S BATTLEGROUNDS
Else if Variable != 0
Run, amp.cmd (second batch file here)
ExitApp
Return