0
votes

I'm very new to this program and haven't really worked on many scripts so I'm not sure where to begin. What I need to do is set hotkeys for my Xbox360 controller that when held (for 3 seconds) launches Steam Big Picture and then while that program is running and the key is held (for 3 seconds) Big Picture will close, if not currently in a game.

This script does half of what I want it to do...

#IfWinNotExist, Steam ahk_class CUIEngineWin32
Joy7::
Process, Exist, Steam.exe
if ErrorLevel
Run, "steam://open/bigpicture"
else
Run, "D:\Program Files (x86)\Steam\Steam.exe" -bigpicture

The only thing I want changed to it is:

  • Joy7 to be changed to the Xbox360 "X" / Guide Button
  • Joy7 (or above key) held for 3 seconds
  • Hold key for 3 seconds while in Big Picture (and not in a game) to close/return to desktop

Any ideas of how to do this? Any help would be much appreciated, thanks!

1

1 Answers

5
votes

I don't have an Xbox controller handy, so I won't be able to help you out with the guide button. KeyHistory or following the Special Keys section in the docs may be able to help you out.

The following code should put you well on your way for the other items. Let me know if you have questions.

#SingleInstance force
Joy7::
    keyDown := A_TickCount
    KeyWait, %A_ThisHotkey%
    If ((A_TickCount-keyDown) > 3000)
    {

        If ProcExists("Steam.exe")
        {
            If WinActive("ahk_exe Steam.exe")
            {
                Process, Close, Steam.exe
                Sleep 50
                Send #d
            }
            Else
                Run, "steam://open/bigpicture"
        }
        Else
            Run, "C:\Program Files (x86)\Steam\Steam.exe" ;-bigpicture
    }
Return

ProcExists(p) 
{    
    Process, Exist, % p
    Return    ErrorLevel
}