I want to write an AutoHotkey script which presses a key X number of times. For example, here's a script which presses Tab 10 times.
Send, {Tab}{Tab}{Tab}{Tab}{Tab}{Tab}{Tab}{Tab}{Tab}{Tab}
While the above solution works, it's a bit unwieldy.
Is there a better solution for sending a key multiple times?
AutoHotkey definitely does not have built-in recording capabilities--you would need to use a third party macro recorder if you don't want to just code the macro from scratch.
Try using Send {Tab 10}
Repeating or Holding Down a Key
To repeat a keystroke: Enclose in braces the name of the key followed by the number of times to repeat it. For example:
Send {DEL 4} ; Presses the Delete key 4 times. Send {S 30} ; Sends 30 uppercase S characters. Send +{TAB 4} ; Presses Shift-Tab 4 times.
Source: AutoHotkey - Send / SendRaw / SendInput / SendPlay / SendEvent: Send Keys & Clicks
This also works with ControlSend and ControlSendRaw
ControlSend, Edit1, {Enter 5}, Untitled - Notepad
If you want the repeat in a loop, let's say every 3 seconds:
#a:: ; Win+a Loop, 10 { SendInput {Tab} Sleep, 3000 }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With