I'm trying to write an AHK script that allows me to do the following:

Press the t key to toggle the 1 key being held down so that it types a bunch of 1's indefinitely until I press the t key again.

Just to be clear: I want it to repeatedly send the 1 key input and not send the command to hold the 1 key down without typing anything.

I'm aware that this could be done with a loop but unsure of how to do it; Although the t key should start and stop the loop. I also don't want the loop to be affected (even if I pressed other keys) unless it is by me manually stopping it using the t key.


If I understand right, you want the key t to start and stop the repeating of the key 1, acting as a switch.

Below is a script that does this, repeating the key at intervals of 200 milliseconds:

repeating1 = 0

if (repeating1 = 0)
    repeating1 = 1
    SetTimer, repeat1, 200
    repeating1 = 0
    SetTimer, repeat1, Off

send, 1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.