Jump to content

searching for more than 1 color


Recommended Posts

  • Moderators

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.

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.

Link to comment
Share on other sites

  • Moderators

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.

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.

Link to comment
Share on other sites

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=
Link to comment
Share on other sites

  • Moderators

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

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.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...