Help with a simple TOGGLE script?

Ask gaming related questions (AHK v1.1 and older)
itisme
Posts: 8
Joined: 21 Sep 2019, 08:44

Help with a simple TOGGLE script?

17 Apr 2021, 19:32

Hi there... I have a macro that enables me to toggle a button to keep pressing it... so I press "a" it types"aaaaaaaaaaaaaaa....." etc etc. I then press "a" again to stop it. If the "a" is repeating... and I simply hold down shift it will type "AAAAAAAAAAAAAAAAAAA". I also have a F11 to set everything off and play a sound.

Code: Select all

F11::
	settimer, pressZero, off
	SoundBeep, 300, 100
Return

a::
	repeata:= not repeata
	if gather
	{
		settimer, pressZero, 300
	}
	else
	{
		settimer, pressZero, off
	}
Return

pressZero:
	Send, {blind}a
Return
What I would love to do is have a way to stop the toggle on another keypress.... so if it is typing "aaaaaaaaaaaaaa" and I press "1" it stops the "a" toggle and types a single "1"?

Is that possible?
User avatar
mikeyww
Posts: 26939
Joined: 09 Sep 2014, 18:38

Re: Help with a simple TOGGLE script?

17 Apr 2021, 20:18

Code: Select all

#MaxThreadsPerHotkey 2
$a::
If on := !on {
 SetTimer, pressZero, 300
 Return
}
~1::
F11::
SetTimer, pressZero, Off
SoundBeep, 300, 100
on := False
Return
pressZero:
Send {Blind}a
Return
itisme
Posts: 8
Joined: 21 Sep 2019, 08:44

Re: Help with a simple TOGGLE script?

19 Apr 2021, 00:11

Hi... Thanks for the reply... this seems to work well... is there way to have a table of keys and test them all with a loop rather than list them all.

The code will stop and type the 1st char if I press 1... so I need to make a 1:: type line for every active key to stop is... is there a way to have a table of keys that "won't stop" it and everything else dose? Or do I need to make a entry for every key on the keyboard that dose stop it?
User avatar
mikeyww
Posts: 26939
Joined: 09 Sep 2014, 18:38

Re: Help with a simple TOGGLE script?

19 Apr 2021, 05:58

You could list every key, or you could use Input, or A_PriorKey with A_TimeIdleKeyboard.
itisme
Posts: 8
Joined: 21 Sep 2019, 08:44

Re: Help with a simple TOGGLE script?

21 Apr 2021, 01:33

ok... how about making the toggle stop on the press of anykey? Is that possible?
User avatar
mikeyww
Posts: 26939
Joined: 09 Sep 2014, 18:38

Re: Help with a simple TOGGLE script?

21 Apr 2021, 05:38

Yes. You can run a timer that checks the A_TimeIdleKeyboard. When that value drops below your threshold, you can issue the toggle. See my earlier post with the link.

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 76 guests