How to reset all Timers with one return?

Ask gaming related questions (AHK v1.1 and older)
Zmrdcz
Posts: 3
Joined: 18 Apr 2021, 02:02

How to reset all Timers with one return?

18 Apr 2021, 02:16

Hello! I have some problems with ny AHK script. I have a autoclicker that check color and click, also I need to restart WEB every 20 seconds, but if I use SetTimer I need to write return to make it periodicity, but I stop the color check and cant go back to it. I tried to make 2 Timers and reset it with one "return" like this:

Code: Select all

SetTimer, Label0, 200

Label0:
SetTimer, Label777, 2000
Goto Label1
	

	Label1:
Click Left 1455, 243,
Click Left 1505, 123,
	
Label777:
SendInput, {F5}
return

but if I will go like this:

SetTimer, Label0, 200

Label0:
SetTimer, Label777, 2000
Goto Label1
	

	Label1:
MouseGetPos, 937, 319,
	PixelGetColor, color, 937, 319, alt
	Var11 = %color%
	if (var11 = 0x0000FF )
	{	
		sleep, 500
		Click Left 1455, 243,
		sleep, 500
		Goto, Label1
	}
	else
	{
		MouseGetPos, 866, 814,
		PixelGetColor, color, 866, 814, alt
		Var6 = %color%
		if (var6 = 0x703B00 )
		{
			Click Left 893, 804,
			sleep, 500
			Goto, Label1
		}
		else
		{
			MouseGetPos, 1082, 448,
			PixelGetColor, color, 1082, 448, alt
			Var16 = %color%
			if ( var16 = 0xFFFFFF )
			{
				Click Left 1453, 242,
				sleep, 500
				Click Left 1453, 242,
				sleep, 500
				Goto, Label1
			}
			else
			{
				MouseGetPos, 1491, 325,
				PixelGetColor, color, 1491, 325, alt
				Var1 = %color%
				if ( var1 = 0x703C00 )
				{
					Click Left 1491, 325,
					sleep, 500
				}
				else
				{
					Goto, Label1
				}
			}
		}

	}
	
	
Label777:
SendInput, {F5}
return
[Mod edit: [code][/code] tags added.]



it doesnt work. How can I release this and whats the feature?
Rohwedder
Posts: 7630
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: How to reset all Timers with one return?

18 Apr 2021, 03:12

Hallo,
your script starts with:

Code: Select all

SetTimer, Label0, 200
Label0:
SetTimer, Label777, 2000
This makes no sense to me!
The timer Label0 with the period 200ms starts and resets every 200ms the timer Label777 with the period 2000ms. The second timer would trigger the first time after 2000ms, but it can't! Every time it is already reseted after 200ms!
Your many GOTOs prove to me that you do not yet fully understand the timer concept.
Try:

Code: Select all

#Persistent
SetTimer, high_Beep, 800
Gosub, high_Beep 		 ;the first high Beep immediately
SetTimer, low_Beep, 3000 ;the first low Beep after 3 seconds
Return

high_Beep:
SoundBeep, 4000, 20 ;high Beep
Return

low_Beep:
SoundBeep, 1000, 20 ;low Beep
Return
Zmrdcz
Posts: 3
Joined: 18 Apr 2021, 02:02

Re: How to reset all Timers with one return?

18 Apr 2021, 03:54

I use 2 timers for 1) Start my bot. It checks color and click 2) Reload the web and then restart all timers with 1 return. I need it to make multiply things, restart and then start again my bot. Or I make something incorrect?
Zmrdcz
Posts: 3
Joined: 18 Apr 2021, 02:02

Re: How to reset all Timers with one return?

22 Apr 2021, 02:46

Everything is working! Thank you very much!

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: sofista and 155 guests