Help. pixelsearch and loop

Ask gaming related questions (AHK v1.1 and older)
ojslyf
Posts: 1
Joined: 23 Feb 2020, 18:18

Help. pixelsearch and loop

23 Feb 2020, 18:36

Hi I've made this code to basically detect a certain color pixel then react to it.
I would like to improve it to keep looping the first if statement until its true then move to the second and third and last statement rather then just looping the whole thing.
Spoiler
User avatar
Xtra
Posts: 2750
Joined: 02 Oct 2015, 12:15

Re: Help. pixelsearch and loop

23 Feb 2020, 19:10

This should give you an idea how to do it.
If you want any after the 1st PixelSearch to loop until found edit those to use loop and break etc.

Code: Select all

F1::
	Loop
	{   ; loops until found:
		PixelSearch, Px, Py, 1119, 656, 1156, 682, 0x414141, 1, Fast
		if (Errorlevel = 0)
		{
			Mouseclick, left, 1230, 773
			Sleep 5000
			break
		}
		sleep 50    ; always a good idea to have sleeps in loops (lower = higher cpu usage)
	}

	PixelSearch, q1, q2, 919, 730, 939, 748, 0x9B7B54, 1, Fast
	if (Errorlevel = 0)
	{
		sleep 1200
		Send {right down}
		sleep 1300
		Send {right up}	
	}

	PixelSearch, ax, ay, 1294, 525, 1382, 597, 0x0378FF, 1, Fast
	If (ErrorLevel = 0)
	{
		send {shift down}
		sleep 150
		send {shift up}
		send {shift down}
		sleep 150
		send {shift up}
	}

	PixelSearch, bx, by, 1251, 386, 1308, 462, 0x0BB0FF, 1, Fast
	if (ErrorLevel = 0)
	{
		sleep 1000
		send {n down}
		sleep 150
		send {n up}
		sleep 150
		send {enter down}
		sleep 150
		send {enter up}
	}	
return

F2::reload
HTH

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], mexican scientist and 70 guests