Skip to content

Instantly share code, notes, and snippets.

@joyrider3774
Created October 7, 2021 02:32
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save joyrider3774/23facbe6664001486a4fc35af868a78c to your computer and use it in GitHub Desktop.
XBox Controller autohotkey script to close or activate the active window (handy with games)
#SingleInstance Ignore
while (true)
{
;back + start -> quit active window
if ((getKeyState("joy7") && getKeyState("Joy8")) || (getKeyState("2joy7") && getKeyState("2Joy8")) || (getKeyState("3joy7") && getKeyState("3Joy8")))
{
WinClose A
sleep 900
}
;back + right stick click -> send esc
if ((getKeyState("joy7") && getKeyState("Joy10")) || (getKeyState("2joy7") && getKeyState("2Joy10")) || (getKeyState("3joy7") && getKeyState("3Joy10")))
{
Send, !{Esc}
}
;back + left stick click -> mouse click in middle of the active window
if ((getKeyState("joy7") && getKeyState("Joy9")) || (getKeyState("2joy9") && getKeyState("2Joy9")) || (getKeyState("3joy9") && getKeyState("3Joy9")))
{
;get window size and click on half position of window
CoordMode, Click, Window
WinGetPos, winX, winY, winWidth, winHeight, A
X := winWidth * 0.5
Y := winHeight * 0.5
Click %X% %Y%
;hacky way to move mouse to lowerright corner
MouseMove, 4000, 4000
}
sleep 100
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment