Minor Help Via Breaking

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
ZeroProxy
Posts: 3
Joined: 17 Dec 2017, 20:57

Minor Help Via Breaking

17 Dec 2017, 21:02

Okay I know this is probably asked quite a few times, I've checked through other forms and tried to make it myself but keep coming up short.

Basically trying to make an auto clicker that follows a set path and then I can click F9 again to deactivate it. It starts just fine and goes through the motions but breaking seems to be a topic I'm just getting a headache since I've tried doing it four different ways. @.@

Code: Select all

#MaxThreadsperHotkey 2

x := 633
y := 264
a := 420
b := 630
c := 500
d := 395
e := 460
f := 370
g := 600
h := 360
i := 190
j := 520
k := 570
l := 215
q := 750
w := 300


f1::MoveClickBack(x, y)
f2::MoveClickBack(a, b)
f3::MoveClickBack(c, d)
f4::MoveClickBack(e, f)
f6::MoveClickBack(g, h)
f7::MoveClickBack(i, j)
f8::MoveClickBack(k, l)
Numpad0::MoveClickBack(q, w)

MoveClickBack(x, y)
{
   local start_x, start_y
   mousegetpos, start_x, start_y
   mouseclick, left, %x%, %y%, 1, 0
   mousemove, %start_x%, %start_y%, 0
}

F9:: 
toggle := !toggle
Loop 50
{
	if toggle
{
		Send {F1} 
		sleep 3000
		Send {Enter}  
		sleep 3000
		Send {Enter}  
		sleep 3000
		Send {Enter}  
		sleep 3000
		Send {Enter}  
		sleep 3000
		Send {F3} 
		sleep 3000
		Send {F4}
		sleep 3000
		Send {F4}
		sleep 3000
		Send {F6}
		sleep 3000
		Send {F7}
		sleep 3000
		Send {F8}
		sleep 3000
		Send {Numpad0}  
		sleep 3000 
		return
}

	else
	{
		break   
	}
}

return

wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: Minor Help Via Breaking

17 Dec 2017, 21:38

The problems seems to be the timing. You would have to wait 12*3 seconds to see the effect of F9.
What is happening is this: you press F9 and the first time Toggle gets set to True and your auto-clicker set off. Good.
When you don't want to auto-click any longer you press F9 again. This starts a new thread where Toggle gets reset to False. The second thread then terminates.
But the first thread only checks after so many seconds before it stops.

You could incorporate mere frequent checks to achieve responsiveness.
ZeroProxy
Posts: 3
Joined: 17 Dec 2017, 20:57

Re: Minor Help Via Breaking

17 Dec 2017, 21:51

wolf_II wrote:The problems seems to be the timing. You would have to wait 12*3 seconds to see the effect of F9.
What is happening is this: you press F9 and the first time Toggle gets set to True and your auto-clicker set off. Good.
When you don't want to auto-click any longer you press F9 again. This starts a new thread where Toggle gets reset to False. The second thread then terminates.
But the first thread only checks after so many seconds before it stops.

You could incorporate mere frequent checks to achieve responsiveness.
Okay, so now I understand. It'll go through the rest of the script before terminating. So how would I make it immediately break once I notice something is wrong or I need to terminate it due to me needing to do something else? It isn't that long of a script, but it's all based on the latency of the game I'm playing. So quickly going through the script is a no-go, sadly.

Sorry, I just started playing around with this.

Also ever since I added the break it only goes through 1 loop of it.
Last edited by ZeroProxy on 17 Dec 2017, 21:54, edited 1 time in total.
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: Minor Help Via Breaking

17 Dec 2017, 21:52

Try this:

Code: Select all

F9::
    toggle := !toggle
    Loop 50
        if toggle
            For each, Key in ["F1","Enter","Enter","Enter","Enter","F3","F4","F6","F7","F8","Numpad0"]
            {
                Send {%Key%}
                sleep 3000
                if toggle
                    Return
            }
        else
            break
Return
I hope that helps.
ZeroProxy
Posts: 3
Joined: 17 Dec 2017, 20:57

Re: Minor Help Via Breaking

17 Dec 2017, 21:58

wolf_II wrote:Try this:

Code: Select all

F9::
    toggle := !toggle
    Loop 50
        if toggle
            For each, Key in ["F1","Enter","Enter","Enter","Enter","F3","F4","F6","F7","F8","Numpad0"]
            {
                Send {%Key%}
                sleep 3000
                if toggle
                    Return
            }
        else
            break
Return
I hope that helps.

It seems to run through the loop only once now before breaking. Same when I added the break in the first place. >>'

I seem to be stuck with a macro that does it once, or a macro that loops 50 times and never stops.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: gongnl, Joey5, RandomBoy, Rohwedder and 375 guests