Jump to content

How to make Pixelsearch, search for more than one color?


Recommended Posts

think the topic says it all what I tried to do was

$coords = PixelSearch ( 295, 280, 815, 525, 0xF85329 OR 0xFCED98 OR 0xB46A4B )

To my understanding this should make the variable $coords become the x, y for the first pixel within the search field with either of the colors

Now I am not used to using pixelsearch so I might be wrong, if so maybe someone could point me in another direction.

Link to comment
Share on other sites

couldn't find the edit button, but I found a possible solution.

Personally I like to keep my scripting code as small as possible so this is in my eyes not the optimal solution, but I figured I would post it in case anyone else have a similar problem.

What I did was do a pixel search for each color, then have it report to a different variable, at the same time adding a counting variable to make sure the next color would not just overwrite the first one. This does however mean that it will take care of the first color no matter of positioning. Not doing whatever color comes first, so input is still wanted :whistle:

Anyways this is what I did after some long thinking and trying.

$coordcount = 1
    $coords1 = PixelSearch ( 295, 280, 815, 525, 16274217 )
        If Not @error AND $coordcount = 1 then
            $clickcoords = $coords1
            $coordcount = 0
        EndIf
    $coords2 = PixelSearch ( 295, 280, 815, 525 , 16575896 )
        If Not @error AND $coordcount = 1 Then
            $clickcoords = $coords2
            $coordcount = 0
        EndIf
    $coords3 = PixelSearch ( 295, 280, 815, 525 , 2762009 )
        If Not @error AND $coordcount = 1 Then
            $clickcoords = $coords3
            $coordcount = 0
        EndIf
    $coords4 = PixelSearch (295, 280, 815, 525 , 16776960 )
        If Not @error AND $coordcount = 1 Then
            $clickcoords = $coords4
            $coordcount = 0
        EndIf
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...