Here's the function with an example:
Code: Select all
F1::PressNHold(A_ThisHotkey, "{space}", 10)
PressNHold(Key, Press := "", Delay := 100) {
While (GetKeyState(Key, "P")) {
SendInput % (Press) ? Press : Key
Sleep % Delay
}
}
This allows, when F1 is pressed, to "spam" the space key with a delay of 10 milliseconds.
To do multiple keys, do as follows:
Code: Select all
F1::PressNHold(A_ThisHotkey, "ab", 10)
PressNHold(Key, Press := "", Delay := 100) {
While (GetKeyState(Key, "P")) {
SendInput % (Press) ? Press : Key
Sleep % Delay
}
}
Upon pressing F1, again, will "spam" ab repeatedly until you let go of F1.
Any questions can be asked here and if you need anything, I'll be having fun under the sun. (Not really because I never go outside :P)