Jump to content

Search for a range of colors on the same pixel.


Recommended Posts

Imagine you are trying to automate something, and in order to do it, you have to check a certain pixel (or many pixels) for a specific color. However, you can't because this pixel is constantly changing color by a tiny bit (slightly transparent) and there is no way to make it opaque.

Is it possible to search 1 specific pixel for a range of colors? Like for example; check pixel for any random shade of white and you do this, but if it's a shade of anything else, do that.

Get what I'm saying? Is this possible?

Edited by shea851
Link to comment
Share on other sites

You could also call PixelGetColor(), and then do something, and then PixelGetColor again, and compare the two, and if the second one is different from the first, preform a different action.

What goes around comes around... Payback's a bitch.

Link to comment
Share on other sites

It does allow for shade variation.. however I have no idea how to use arrays...

Is there a way to do this without involving arrays in any way?

;checks 1 pixel to see if it is white or within 100 shades of white, if it is, the $coord will be set to those coords, if it is not, $coord will be set to nothing?
$coord = PixelSearch( 893, 75, 893, 75, 0xFFFFFF, 100 )

;if $coord is equal to those coords, then it'll do something
Func check()
    If ($coord[0] & $coord[1]) = (893, 75) Then

I keep getting some subscript error, I know my coding is flawed, but i'm not sure how else to use this Pixelsearch function...

Edited by shea851
Link to comment
Share on other sites

They are probably easy if you've used them at least once. Which I haven't :shocked:

Anyways though, I found these lines of code elsewhere in the forum, which look like they'll help me get started on my first array...

Func SomeFunction()
    $coord = PixelSearch( 28, 59, 28, 59, 0x7B96DE, 10 )
    If IsArray($coord) Then;If pixel color is 0x7B96DE
        MouseClick("left", 985, 359, 1, 1)                          ;then move to mouse coordinates (28, 59)
        Sleep(5000)                                 ;Wait 5 seconds
        SomeOtherFunction()                         ;Start Some Function
    EndIf
EndFunc

If not, i'll be back! Thanks again for the help.

Edited by shea851
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...