Thanks for posting this! I've made tweaks as I was having issues with the exitapp section. Here are the two scripts I came up with based on yours, hoping it helps others
I've spent like half a day on this so wanted to share my learns. link here: https://www.autohotkey.com/boards/viewtopic.php?f=18&t=63827&p=273602#p273602
method one
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
Run, openliero.exe
#IfWinActive AHK_exe openliero.exe ;
; Player1
;KeyPressed::KeyItThinksIPressed
w::Up ;when pressing the W key, the game registers that up was hit instead
a::Left
s::Down
d::Right
LControl::Enter ;shoot
;Escape key
5::Escape
6::Esc
; Player2
#IfWinNotExist ahk_exe E:\Windows\Liero 1.36\openliero.exe ;
w::
send w
Exitapp
return
s::
send s
exitapp
return
a::
send a
exitapp
return
d::
send d
exitapp
return
LControl::
send ^
exitapp
return
5::
send 5
exitapp
return
6::
send 6
exitapp
return
method two
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
Run, openliero.exe
#Persistent ;only exits on an exitapp command
WinWait, ahk_exe openliero.exe, , 5
SetTimer, CheckForWindow, 5000 ; check every 5 seconds
#IfWinActive AHK_exe openliero.exe ;
; Player1
;KeyPressed::KeyItThinksIPressed
w::Up ;when pressing the W key, the game registers that up was hit instead
a::Left
s::Down
d::Right
LControl::Enter ;shoot
;Escape key
5::Escape
6::Esc
; Player2
CheckForWindow:
IfWinNotExist, ahk_exe openliero.exe
{
ExitApp
Return
}
Still trying to figure out the best method, but hoping this helps others that find this thread. both confirmed working.