Cycling through keypresses with one button Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
elehexx

Cycling through keypresses with one button  Topic is solved

28 Mar 2017, 22:51

Hello, this script cycles through buttons F1-3 in a loop by pressing the key 'a' over and over. What I want to alter about this is also have it send a '0' keypress every time as well, how can I do that?

a::
key++ ; this will help cycling through the keys depending on its value
if key = 1
Send, {F1}
else if key = 2
Send, {F2}
else if key = 3
{
Send, {F3}
key = 0 ; return to the original state... do this on the last hotkey you would like to send
}
return
MaxAstro
Posts: 557
Joined: 05 Oct 2016, 13:00

Re: Cycling through keypresses with one button

29 Mar 2017, 09:20

Just add Send, 0 right above key++.

Edit: You can also simplify the original code a bit. Here is an example that does everything you want:

Code: Select all

a::
	Send, 0
	key++
	Send {F%key%}
	if key = 3
		key = 0
	return
If you want it to send a 0 after pressing F1/F2/F3, move Send, 0 down to just above return.
Last edited by MaxAstro on 29 Mar 2017, 09:27, edited 1 time in total.
Nightwolf85
Posts: 302
Joined: 05 Feb 2017, 00:03

Re: Cycling through keypresses with one button

29 Mar 2017, 09:23

You can try just putting a 0 either before or after the F key, depending on when you want it sent, like so:

Code: Select all

Send, {F1}0
OR

Code: Select all

Send, 0{F1}


MaxAstro's code above looks like the best suggestion.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: filipemb, Google [Bot], mikeyww and 332 guests