Toggle 3 keys

Ask gaming related questions (AHK v1.1 and older)
Thraxx
Posts: 1
Joined: 20 Apr 2024, 00:13

Toggle 3 keys

20 Apr 2024, 00:35

I'm trying to press s and toggle between 1, 2, and 3 and have it reset to 1

Code: Select all

{
s::
toggle := !toggle
if toggle
	Send {2}
else
	Send {3}
return

$1::					; $ to prevent endless loop

toggle := false			; reset the (boolean) variable toggle
return
}
[Mod edit: Added [code][/code] tags. Please use them yourself when posting code!]
[Mod edit: Moved topic from 'Ask for Help (2) > Gaming' to v1 help since this is v1 code.]
Rohwedder
Posts: 7697
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Toggle 3 keys

20 Apr 2024, 04:10

Hallo,
perhaps?:

Code: Select all

s::Send,% ++N:=Mod(0 N, 3) ; sends 1-3 cyclic
~1::N=1 ; Key 1 performs its native function and sets N to 1
the tilde ~ activates the keyboard hook just like $
https://www.autohotkey.com/docs/v1/Hotkeys.htm#Tilde

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: Performance and 36 guests