I made a script for looping a sequence of inputs but it doesn't work.
I want to run these inputs whenever I press 8 on my keyboard. When I press 8, it should process the inputs. And after 12 seconds, it will run the inputs again for a total of 13 times. However, If I press 8 on my keyboard while the loop is active, it will turn off the loop. Pressing 8 once more will reset the loop and begin it. Can you help me create this loop? Thank you kindly!
I want to run these inputs whenever I press 8 on my keyboard. When I press 8, it should process the inputs. And after 12 seconds, it will run the inputs again for a total of 13 times. However, If I press 8 on my keyboard while the loop is active, it will turn off the loop. Pressing 8 once more will reset the loop and begin it. Can you help me create this loop? Thank you kindly!
CODE:
LoopStatus := 0 ; 0: Not running, 1: Running
8::
if (LoopStatus = 0)
{
LoopStatus := 1
SetTimer, MyLoop, 12000
}
else
{
LoopStatus := 0
SetTimer, MyLoop, Off
}
return
MyLoop:
try
{
Sleep, 25
BlockInput, On
Send, 2
Sleep, 40
Send, s
Sleep, 40
Send, 1
Sleep, 40
Send, s
Sleep, 40
Send, 5
Sleep, 25
}
finally
{
BlockInput, Off
Sleep, 25
Loop, 0xFF
if GetKeyState(Key := Format("VK{:X}", A_Index))
SendInput, {%Key% up}
}
return
Statistics: Posted by acnl — 24 minutes ago