The idea is to release"W\A\S\D" on hotkey press, do the required combo (since it gets messed up if during the combo any of the keys are pressed) and push them down again once the combo is done.
I was trying to use BlockInput to kinda avoid it, but blockinput doesn't really seem to work well with keywait, however if I don't use keywait - the hotkey goes on a loop.
Code: Select all
#NoEnv
#Persistent
#IfWinActive, ahk_exe required_app.exe
SetCapsLockState, AlwaysOff
ListLines Off
SetBatchLines, -1
SetKeyDelay, 0, 15
SetWinDelay, -1
SetControlDelay, -1
SendMode, Input
MyTimerPrior := -1
fixTimer1:
MyTimerPrior := -1
SetTimer, fixTimer1, Delete
return
fixKeys:
if (GetKeyState("w", "P") && !GetKeyState("w", "L")) {
SendInput, {Blind}{w down}
}
if (GetKeyState("a", "P") && !GetKeyState("a", "L")) {
SendInput, {Blind}{a down}
}
if (GetKeyState("d", "P") && !GetKeyState("d", "L")) {
SendInput, {Blind}{d down}
}
if (GetKeyState("s", "P") && !GetKeyState("s", "L")) {
SendInput, {Blind}{s down}
}
return
XButton1:
SendInput, {Blind}{w up}{s up}{d up}{a up}
Sleep, 2
if (MyTimerPrior == 0) {
SendInput, {Blind}{Space down}
Sleep, 1
SendInput, {Blind}{s down}
Sleep, 1
SendInput, {Blind}{s up}{Space up}
Sleep, 1
}
Sleep, 2
SendInput, {Blind}{s down}
Sleep, 1
SendInput, {Blind}{s up}
Sleep, 3
SendInput, {Blind}{w down}
Sleep, 1
SendInput, {Blind}{w up}
Sleep, 3
SendInput, {Blind}{RButton}
MyTimerPrior := 0
SetTimer, fixTimer1, 700
return
~*$XButton1::
gosub, XButton1
KeyWait, XButton1
gosub, fixKeys
return
~*$w::return
~*$a::return
~*$s::return
~*$d::return
w & XButton1::
gosub, XButton1
KeyWait, XButton1
gosub, fixKeys
return
a & XButton1::
gosub, XButton1
KeyWait, XButton1
gosub, fixKeys
return
s & XButton1::
gosub, XButton1
KeyWait, XButton1
gosub, fixKeys
return
d & XButton1::
gosub, XButton1
KeyWait, XButton1
gosub, fixKeys
return