Here is the code:
Code: Select all
%HKeyHkKeyT1%toggle := !%HKeyHkKeyT1%toggle
If %HKeyHkKeyT1%toggle {
While %HKeyHkKeyT1%toggle {
ImageSearch, , , 0, 0, 1000, 80, % "*10 " HKeyHkS1T1 "Timer.png"
If ErrorLevel = 1
ImageSearch, , , 0, 0, 1000, 80, % "*10 " HKeyHkS1T1 "Timer3.png"
if ErrorLevel = 0
SetEnv, %HKeyHkS1T1%Timer, True
if ErrorLevel = 1
SetEnv, %HKeyHkS1T1%Timer, False
If %HKeyHkS1T1%timer = False
{
ImageSearch, , , 1575, 1020, 1630, 1075, % "*10 " HKeyHkS1T1 "-" HKeyHkKeyT1 ".png"
If ErrorLevel = 0
;The random amounts of Left clicks happen around here when holding down the left button and reset the loop after each click but won't show on the log. This didn't happen when this script wasn´t using variables. Sometimes it works as its supposed, sometimes sends a few clicks before sending the right input. Most times sends 1 left click then a bit later (Sleep, 1000) the correct send input.
Send, {%HKeyHkKeyT1%}
If (ErrorLevel = 1) {
MouseGetPos, Xpos, Ypos
BlockInput, MouseMove
GetKeyState, LButtonstate, LButton
If LButtonstate = D
Mouseclick, , , , , , U
MouseClick, , KeyXt1_Hk, KeyYt1_Hk
MouseClick, , %HKeyHkS1T1%X, %HKeyHk1T1%Y
Send, {%HKeyHkKeyT1%}
If LButtonstate = D
Mouseclick, , , , , , D
MouseMove, Xpos, Ypos
BlockInput, MouseMoveOff
}
}
Sleep, 1000
}
Return
}