Help with loop toggle

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
CallMeSeby
Posts: 8
Joined: 23 Jun 2017, 14:45

Help with loop toggle

25 Jun 2017, 04:29

Code: Select all

#MaxThreadsPerHotkey 2

$x::
    Toggle := !Toggle
    while Toggle
    {
		
       Send, {!}flipcoin 25
	Send {Enter down}
	sleep 10
	Send {Enter up}
	Sleep 60000
	Send, Sal
	Send {Enter down}
	sleep 10
	Send {Enter up}
	Sleep 125000
	
    }
return


Can somebody correct this (this cant be turned off i want to toggle it with ^s on and ^s off. Whats wrong with this ? btw tell me why you modified and one more thing dont change anything thats in the loop { } (the send and sleep) you can add what you want, also dont delete anything.I want you to be noob friendly :D
User avatar
Exaskryz
Posts: 2882
Joined: 17 Oct 2015, 20:28

Re: Help with loop toggle

25 Jun 2017, 07:07

My question for you is: Does this work if you press x? I don't see any reason it shouldn't. If it does, try just changing the $x:: into ^s::. Do that because x is the hotkey in the current code, and you want it to be ctrl+s. The ^ means ctrl. The $ on the original $x:: hotkey is there to prevent another part of the script activating that hotkey. If the hotkey were just x::, then if I were to use in some part of the script Send Exaskryz, the x in "Exaskryz" would trigger the hotkey x::. (Another way to look at it is, $ means it should only be activated by human input.)
CallMeSeby
Posts: 8
Joined: 23 Jun 2017, 14:45

Re: Help with loop toggle

25 Jun 2017, 12:32

Hi ! I tried what you said but it is even weirder !!!I changed $x with ^x...it does not even activates... I leave the x just like this without any $ or ^ and it starts...but to stop, no way...Thanks for trying tho !
User avatar
Spawnova
Posts: 554
Joined: 08 Jul 2015, 00:12
Contact:

Re: Help with loop toggle

25 Jun 2017, 14:01

I've always had issues with loops inside hotkeys, it seems to be a problem with the thread.

if you add a timer it should solve your problem

Code: Select all

x:: ;$ needed if sending keys contain x
    Toggle := !Toggle
    settimer,doloop,1
return

doloop:
settimer,doloop,off
while (Toggle) {	
	Send, {!}flipcoin 25
	Send {Enter down}
	sleep 10
	Send {Enter up}
	Sleep 600
	Send, Sal
	Send {Enter down}
	sleep 10
	Send {Enter up}
	Sleep 1250
}
return

f8::exitapp
f9::reload
I've never understood why this happens, but adding a settimer is a quick fix

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: coder96, Google [Bot], RandomBoy, Rohwedder and 177 guests