Here are my attemps, also using only one timer. Both tested.
Toggleable version:
#NoEnv
#SingleInstance, Force
#Persistent
#MaxThreadsPerHotkey 2
SetTitleMatchMode, 2
SetBatchLines, -1
SetKeyDelay, 50,50
DetectHiddenWindows, On
CoordMode, Pixel, Screen
CoordMode, Mouse, Screen
CoordMode, Tooltip, Screen
Loop, [color=#BF40FF]3[/color] {
Toogle%A_Index% := 0
Hotkey, [color=#BF0000]F[/color]%A_Index%, ToggleLabel
}
SetTimer, SpamKeyRoutine, 50
Return
;------------------------------------------------
ToggleLabel:
Key := SubStr(A_ThisHotkey,0)
Toggle%Key% := !Toggle%Key% + 1
Return
;------------------------------------------------
SpamKeyRoutine:
[color=#FF0000]TEXT := ""[/color]
Loop, [color=#BF40FF]3[/color] {
[color=#FF0000]TEXT .= "`t" Toggle%A_Index%[/color]
If (Toggle%A_Index% >= 1)
Toggle%A_Index%--
If (Toggle%A_Index% == 1) {
[color=#FF8000]Send, %A_Index%[/color]
Random, Time, 1, 6 [color=#008000]; 1*50ms ~ 6*50ms , because the routine runs every 50ms[/color]
Toggle%A_Index% := Time+1
}
}
[color=#FF0000]TOOLTIP, % SUBSTR(TEXT,2)[/color]
Return
;------------------------------------------------
~Esc::ExitAppVersion which requires holding F1~F3:
#NoEnv
#SingleInstance, Force
#Persistent
#MaxThreadsPerHotkey 2
SetTitleMatchMode, 2
SetBatchLines, -1
SetKeyDelay, 50,50
DetectHiddenWindows, On
CoordMode, Pixel, Screen
CoordMode, Mouse, Screen
CoordMode, Tooltip, Screen
Loop, [color=#FF2222]3[/color]
Key%A_Index% := 0
SetTimer, SpamKeyRoutine, 50
Return
;------------------------------------------------
SpamKeyRoutine:
Loop, [color=#FF2222]3[/color] {
If (Key%A_Index% > 0)
Key%A_Index%--
Else If GetKeyState( "F" A_Index , "P" ) {
[color=#FF8000]Send, %A_Index%[/color]
Random, Time, 1, 6 [color=#008000]; 1*50ms ~ 6*50ms , because the routine runs every 50ms[/color]
Key%A_Index% := Time
}
}
Return
;------------------------------------------------
~Esc::ExitApp