MButton Up to toggle on off a loop script Topic is solved

Ask gaming related questions (AHK v1.1 and older)
kilokore

MButton Up to toggle on off a loop script  Topic is solved

25 Jan 2016, 10:44

Hi,

I'm trying to create a script where on MButton Up, I can toggle on or off a loop script, which will do various Send's and Sleep's.
I have tried writing this with the following:

Code: Select all

MButton UP:: Toggle := Toggle ? 0 : 1
#If Toggle
but no matter what i put after this, whether it be loop or a command, I cannot get another 'MButton Up' to toggle it off.

So ideally:
1. On MButton Up, loop starts (send a every 15 seconds)
2. On another MButton Up, loop ends, and the script is paused

Please help. Thanks,
Shadowpheonix
Posts: 1259
Joined: 16 Apr 2015, 09:41

Re: MButton Up to toggle on off a loop script

25 Jan 2016, 16:27

Something in the code you have after the #If Toggle is interfering. Most likely your other code is holding down Shift or Ctrl or something. Try changing MButton Up:: to *MButton Up::. If that does not help, then please post the rest of your script.
kilokore

Re: MButton Up to toggle on off a loop script

25 Jan 2016, 21:13

Hi,
I've made changes to my script as follows:

Code: Select all

toggle = 0
Mbutton UP::
Toggle := !Toggle
While Toggle{

	Send q
	Sleep 15
	Send w
	Sleep 2000
}
return
basically the goal is to:
1. Press MButton and release, which will start the loop that:
2. sends q followed by w, wait 2 seconds and repeat until:
3. I press and release MButton again
4. Repeat 1 as needed

Right now the code works for 1 and 2, but won't stop after the second MButton press.
Any help on this would be greatly appreciated.

Thanks,
Shadowpheonix
Posts: 1259
Joined: 16 Apr 2015, 09:41

Re: MButton Up to toggle on off a loop script

26 Jan 2016, 09:45

Ah. You need to add a line reading #MaxThreadsPerHotkey 2 to the top of your script.
kilokore

Re: MButton Up to toggle on off a loop script

26 Jan 2016, 13:37

Thanks! I think that might have done the trick.

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: prototype_zero, Shoobis and 39 guests