Spamming a key too fast seems to be difficult to interrupt. My code essentially reduces to this:
Code: Select all
SpamKey()
{
Send *
delay := 20
SetTimer, SpamKey, %delay%
}
q::
SetTimer, SpamKey, Delete
Return
s::
SpamKey()
Return
The output is something like this:
Code: Select all
**********Q****************************Q*************
where Q (why is it capital anyway??) are the times I've tried to break the spam. The same behaviour occurs if I implement using the Sleep command. Why is this the case? Also I have another spam routine that acts like this:
Code: Select all
g_isKeyPress := True
Spam()
{
global g_isKeyPress
g_isKeyPress := !g_isKeyPress
if (g_isKeyPress)
{
Send *
funct := Func("Spam").Bind(False)
SetTimer, %funct%, -20
}
else
{
funct := Func("Spam").Bind(True)
SetTimer, %funct%, -600
}
}
q::
SetTimer, Spam, Delete
Return
s::
Spam()
Return
It essentially Sends a key input, waits 20ms, waits a further 600ms, and repeats. This routine is far easier to interrupt, but still sometimes fails to resister 'q' to break the timer. It seems to be if a timer has a small delay (here it is 20ms, but I've also noticed this with a delay of 50ms) it is difficult to interrupt. Why is this and what can I do for a workaround? Workarounds I've tried without success:
- Using the sleep command
- Breaking by using a global flag and checking the flag in the spamming routine