Sign in to follow this  
Followers 0
=sinister=

searching for more than 1 color

7 posts in this topic

is there a way to search the screen with more than 1 pixel, but fast? the only thing I found was pixelsearch but thats only 1 color...

Share this post


Link to post
Share on other sites



Try looking at the shade variation sinister. You posted this question yesterday on pixelsearch, I gave you the link... but you said it was a bit complicated.

It looked like Larry was just waiting on someone to turn that into C++ code to add it in, is what I gathered from the post.

If they are 2 totally different "specific" colors, you'll need to run 2 options of the PixelSearch.

Local $Pix1 = PixelSearch(0, 0, 100, 100, 0x000000, 0, 2); notice the last one, stepping 2 pixels to speed it up
Local $Pix2 = PixelSearch(0, 0, 100, 100, 0xFF0000, 0, 2)

If $Pix1 <> 1 Or $Pix2 <> 1 Then
;Do something
EndIf

I gave an example with stepping 2 pixels to speed up the current PixelSearch.


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

so if I had 3 pixels to search for, would I change the 2 to a 3?

Share this post


Link to post
Share on other sites

so if I had 3 pixels to search for, would I change the 2 to a 3?

The "2" is not a "pixel" to search for, it's how many pixels to skip while searching. You can make that any integer higher than 1, but will skip that many pixels.

As per my post, and the help file: You can do "Shade" vaiations where the "0" is, if the colors are close, and they don't have to be specific. If the colors have to be specific, then you must use "2" different pixelsearch() functions as my example gave you.


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

great, thanks, one more question, do you think the following code would work?

Local $Pix1 = PixelSearch(0, 0, 100, 100, 0x000000, 0, 2)
Local $Pix2 = PixelSearch(0, 0, 100, 100, 0xFF0000, 0, 2)
If $Pix1 <> 1 Or $Pix2 <> 1 Then
MouseClick('Right', $Pix1[0], $Pix1[1], 1, 0)
MouseClick('Right', $Pix2[0], $Pix2[1], 1, 0)
Sleep(2000)
EndIf
Edited by =sinister=

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

great, thanks, one more question, do you think the following code would work?

Local $Pix1 = PixelSearch(0, 0, 100, 100, 0x000000, 0, 2)
Local $Pix2 = PixelSearch(0, 0, 100, 100, 0xFF0000, 0, 2)
If $Pix1 <> 1 Or $Pix2 <> 1 Then
MouseClick('Right', $Pix1[0], $Pix1[1], 1, 0)
MouseClick('Right', $Pix2[0], $Pix2[1], 1, 0)
Sleep(2000)
EndIf
Probably not just like that... Try this:

Local $Pix1 = PixelSearch(0, 0, 100, 100, 0x000000, 0, 2)
Local $Pix2 = PixelSearch(0, 0, 100, 100, 0xFF0000, 0, 2)
If $Pix1 <> 1 Or $Pix2 <> 1 Then
    If IsArray($Pix1) Then MouseClick('Right', $Pix1[0], $Pix1[1], 1, 0)
    If IsArray($Pix2) Then MouseClick('Right', $Pix2[0], $Pix2[1], 1, 0)
Sleep(2000)
EndIf

Otherwise, it looks like it would throw you an error is one of them was not found or "@error"

Edit:

Double Posted

Edited by SmOke_N

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

alright, thanks. I'll test it out later and give ya some feedback, im too lazy to right now. lol.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0