Binding a key for a Sequence

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Geoff M
Posts: 2
Joined: 02 Aug 2018, 04:19

Binding a key for a Sequence

02 Aug 2018, 15:53

Hey guys,

I'm looking to have a script that will allow me to press a single key over and over again but bind to many keys.
EG: Press {E} once and it will press {1}, press {E} again and then it will press {2} and so on, once it gets to say {5} the script will start again. Also if possible when I right click it starts the sequence from the beginning.

I have been able to make a sequence that automatically presses the keys when I press {E} however I want to be able to step it down each time I press {E},

Thank you.
User avatar
Exaskryz
Posts: 2882
Joined: 17 Oct 2015, 20:28

Re: Binding a key for a Sequence

02 Aug 2018, 19:41

This is possible with a counting variable and an If statement.

Code: Select all

var:=0 ; start this at zero
e::
var++ ; increments the variable by 1
If (var=1)
    Send 1
else if (var=2)
    Send 2
; add in 3 and 4, to make sure you understand what is going on
else if (var=5)
    {
    Send 5
    var:=0 ; reset to zero
    }
return
You can use RButton::var:=0 to reset the variable, or you may want to use var:=1 and Send 1 if you want the right click to also do the action e normally does.
Geoff M
Posts: 2
Joined: 02 Aug 2018, 04:19

Re: Binding a key for a Sequence

03 Aug 2018, 00:20

Thank you so much :)

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Ragnar and 343 guests