Need help double colordetecting

Ask gaming related questions (AHK v1.1 and older)
unclenicksonn
Posts: 2
Joined: 03 Jul 2020, 00:27

Need help double colordetecting

03 Jul 2020, 00:48

Good morning everyone!

Recently I started using autohotkey and i really got addicted to it! My knowledge is very basic but i am learning really fast for someone who does not have some kind of IT background :) (I am proud of what i am capable of doing already).

Now i am trying to write a script that has color detection, but there is a posibility that the color changes to a single other color. I want to write a code that looks for the primary color (green, i got the color code :)) (got it working untill here) but if that color is not there i want it to detect the secondary color. this is new for me and i don't quite know how to get this in my code.

This is what i got so far:

Code: Select all

1::
Loop
{
PixelSearch, x, y, 0, 0, %A_ScreenWidth%,%A_ScreenHeight% , COLORCODE, Fast
Click,%x%,%y%
sleep 1000
}

esc::ExitApp


Is there any possibility to add a second color when the first one is not found?

Because i don't want to keep asking questions and i want to learn of it, maybe with some explanation so i can do this on my own in the future :)


Thanks in advance,

Kind regards,
Nick
Last edited by BoBo on 03 Jul 2020, 01:14, edited 1 time in total.
Reason: Moved to Gaming section. Added [code][/code]-tags.
Rohwedder
Posts: 7676
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Need help double colordetecting

03 Jul 2020, 01:34

Hallo,
ErrorLevel is set to 0 if the color was found in the specified region.
Try:

Code: Select all

1::
Loop
{
	PixelSearch, x, y, 0, 0, %A_ScreenWidth%, %A_ScreenHeight%, COLORCODE, Fast
	IF !(ErrorLevel = 0) ;COLORCODE was not found
		PixelSearch, x, y, 0, 0, %A_ScreenWidth%, %A_ScreenHeight%, COLORCODE2, Fast
	IF (ErrorLevel = 0) ;COLORCODE or COLORCODE2 was found
		Click,%x%,%y%
	sleep 1000
}
esc::ExitApp
unclenicksonn
Posts: 2
Joined: 03 Jul 2020, 00:27

Re: Need help double colordetecting

03 Jul 2020, 01:40

I think you just solved my entire problem! thank you so much!

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: kryptooo and 58 guests