my loop pixelsearch if not found is messed up Topic is solved

Ask gaming related questions (AHK v1.1 and older)
kentpachi
Posts: 152
Joined: 15 May 2016, 01:23

my loop pixelsearch if not found is messed up

Post by kentpachi » 19 Dec 2022, 08:57

Code: Select all

loop
{
; check if its in za warudo then find a b c d e
CoordMode, Pixel, Window
PixelSearch, FoundX, FoundY, 981, 1012, 981, 1012, 0x3FDE45, 0, Fast RGB
If ErrorLevel = 0

	{
;Check a
CoordMode, Pixel, Window
PixelSearch, FoundX, FoundY, 1626, 1007, 1626, 1007, 0x3FDE45, 0, Fast RGB
If ErrorLevel
        {
	  Send, {3 down}
        Sleep 20
        Send, {3 up}
		sleep, 3500	
		}


sleep, 250	
	
	
	}

  ; check b
CoordMode, Pixel, Window
PixelSearch, FoundX, FoundY, 1792, 975, 1792, 975, 0x3CD241, 20, Fast RGB
If ErrorLevel
        {
	  Send, {5 down}
        Sleep 20
        Send, {5 up}
		sleep, 3500	
		}


; check c

CoordMode, Pixel, Window
PixelSearch, FoundX, FoundY, 1601, 975, 1601, 975, 0x3FDE45, 5, Fast RGB
If ErrorLevel = 0
	     {
	  Send, {4 down}
        Sleep 20
        Send, {4 up}
		sleep, 5500	
		}


sleep, 250


; check d
CoordMode, Pixel, Window
PixelSearch, FoundX, FoundY, 406, 1007, 406, 1007, 0xD3704C, 0, Fast RGB
If ErrorLevel = 0
  {
	   Send, {7 down}
       Sleep 20
       Send, {7 up}
	   sleep 200
	   Send, {8 down}
       Sleep 20
       Send, {8 up}
       sleep, 7200	
  }



sleep 150

; check e

CoordMode, Pixel, Window
ImageSearch, FoundX, FoundY, 1649, 1018, 1834, 1055, *20 e.png
If ErrorLevel = 0
	{
	   Send, {9 down}
       Sleep 20
       Send, {9 up}
       sleep, 1600	
  }

sleep 550


	
	}
[Mod edit: Changed c tags to code tags.]

first it will find the pixel the world
if its found, it will search pixel a, b, c, d, e

A and B ------- ErrorLevel
while
C, D ,and E ---- ErrorLevel = 0


the A and B is pressing the even even tho the pixel was found, C D and E perfectly works.

Can anyone why the A and B pixelsearch is pressing they keys even tho the pixel is found ?

gregster
Posts: 9113
Joined: 30 Sep 2013, 06:48

Re: my loop pixelsearch if not found is messed up

Post by gregster » 19 Dec 2022, 09:08

Please generally use code tags instead of c tags when you post more than one or (very few) lines of code.
It's the fifth button from the left in the full editor. Thank you!

kentpachi
Posts: 152
Joined: 15 May 2016, 01:23

Re: my loop pixelsearch if not found is messed up

Post by kentpachi » 19 Dec 2022, 10:23

gregster wrote:
19 Dec 2022, 09:08
Please generally use code tags instead of c tags when you post more than one or (very few) lines of code.
It's the fifth button from the left in the full editor. Thank you!
noted

User avatar
andymbody
Posts: 996
Joined: 02 Jul 2017, 23:47

Re: my loop pixelsearch if not found is messed up  Topic is solved

Post by andymbody » 19 Dec 2022, 12:52

I would say it's working as designed... make sure you have the Errorlevels for each search setup correctly. Also check the NESTING of the IF statements

Errorlevel 0 -------> FOUND
IF Errorlevel = 0 --> if FOUND

Errorlevel 1 -------> NOT found
Errorlevel 2 -------> NOT found
IF Errorlevel ------> if NOT found

I posted YOUR code below ... notice what is being asked in each of the IF statements

Also note that only (a) is nested. (b,c,d,e) are NOT nested - was this intentional?

Code: Select all

loop
{
	; check if its in za warudo then find a b c d e
	CoordMode, Pixel, Window
	PixelSearch, FoundX, FoundY, 981, 1012, 981, 1012, 0x3FDE45, 0, Fast RGB
	If ErrorLevel = 0	; if FOUND
	{
		; FOUND - Check a		(the ONLY nested search)
		CoordMode, Pixel, Window
		PixelSearch, FoundX, FoundY, 1626, 1007, 1626, 1007, 0x3FDE45, 0, Fast RGB
		If ErrorLevel		; if NOT found
		{
			; NOT found		1 or 2 = NOT found
			Send, {3 down}
			Sleep 20
			Send, {3 up}
			sleep, 3500	
		}
		sleep, 250	
	}

	; check b
	CoordMode, Pixel, Window
	PixelSearch, FoundX, FoundY, 1792, 975, 1792, 975, 0x3CD241, 20, Fast RGB
	If ErrorLevel		; if NOT found
	{
		; NOT found		1 or 2 = NOT found
		Send, {5 down}
		Sleep 20
		Send, {5 up}
		sleep, 3500	
	}

	; check c
	CoordMode, Pixel, Window
	PixelSearch, FoundX, FoundY, 1601, 975, 1601, 975, 0x3FDE45, 5, Fast RGB
	If ErrorLevel = 0	; if FOUND
	{
		; FOUND			0 = FOUND
		Send, {4 down}
		Sleep 20
		Send, {4 up}
		sleep, 5500	
	}
	sleep, 250

	; check d
	CoordMode, Pixel, Window
	PixelSearch, FoundX, FoundY, 406, 1007, 406, 1007, 0xD3704C, 0, Fast RGB
	If ErrorLevel = 0	; if FOUND
	{
		; FOUND			0 = FOUND
		Send, {7 down}
		Sleep 20
		Send, {7 up}
		sleep 200
		Send, {8 down}
		Sleep 20
		Send, {8 up}
		sleep, 7200	
	}
	sleep 150

	; check e
	CoordMode, Pixel, Window
	ImageSearch, FoundX, FoundY, 1649, 1018, 1834, 1055, *20 e.png
	If ErrorLevel = 0	; if FOUND
	{
		; FOUND			0 = FOUND
		Send, {9 down}
		Sleep 20
		Send, {9 up}
		sleep, 1600	
	}
	sleep 550
}

Post Reply

Return to “Gaming Help (v1)”