Steam – Detect Steam game launch

steam

I have a script (.ahk) that I want to run when I launch a game from Steam, but me and many others I know that want this use the Steam UI to launch the game, so making a desktop shortcut is out of the running, and I don't want a script that runs in the background constantly. Is there a way to detect Steam launching a game or tell Steam to start additional programs?

Best Answer

Even though I'm not sure if this question should be asked in Arqade:

XButton2::
IfWinActive, Spotify
{
    MsgBox, The window here is spotify, add your code here, change game up
    return
}
IfWinActive, Idle Master
{
    MsgBox, The window here is idle master, add your code here, change game up
    return
}
IfWinActive, Counter-Strike: Global Offensive
{
    MsgBox, The window here is csgo, add your code here, change game up
    return
}
return

Also be aware that AHK is kind of in a VAC gray-zone, see here for an article I just wrote.