This is another way to make key repeatedly send itself while held:
#usehook ;*1
hotkey, f1, spam ;*2
return
spam: ;*3
{
while getkeystate(a_thishotkey, "p") ;*4
{
sleep, 20 ;*5
sendinput, {%a_thishotkey%} ;*6
}
}
return
end::exitapp ;*7
/*
1 Directs subsequent hotkeys to use the keyboard hook.
2 Uses Hotkey Command to create a f1 button hotkey tied to the spam subroutine.
3 Spam subroutine label. When called, any code below it will run.
4 While loop and getkeystate, will loop as long as the originating hotkey is held.
5 20ms sleep between loops.
6 Each loop run sends whichever hotkey originated the subroutine.
7 Emergency shutdown.
*/
This code can be expanded by adding other hotkey command at thet top. The same subroutine will work for any number of keys ( provided they are pressed one at a time).