Jump to content

Recommended Posts

Posted

Hi! I have two colors ... red 5901320 and black 1580056.

I test a pixel for those colors with PixelGetColor but sometimes the color differs slighty ... how can decide if its black or red ... ?

thanks in advance

Posted

PixelSearch ( left, top, right, bottom, color [, shade-variation] [, step]] )

when looking for two colors

just use it twice....

If PixelSearch(red) = "red" or PixelSearch(black) = "black" then....

8)

NEWHeader1.png

Posted

sorry i didnt really understand your answer ...

i know the coordinates of the pixel and i just want to know if its red or black ... light red dark red or light black, dark black

i just want to know if its more red or more black

thanks

Posted

Try this, change the pixel coordinates to match the pixel you wish to check.

HotKeySet( "{Esc}", "test_pixel" )

$RED = Dec( "FF0000" )
$BLACK = 0

While 1
        Sleep( 500 )
WEnd

Func test_pixel()
    $color = PixelGetColor( 300, 160 )
    $color = Dec( $color )
    
    $red_diff = Abs( $RED - $color )
    $black_diff = $color - $BLACK

    If $red_diff > $black_diff Then
        MsgBox( 0, "Color Match", "The pixel color is more black than red." )
    ElseIf $black_diff > $red_diff Then
        MsgBox( 0, "Color Match", "The pixel color is more red than black." )
    Else
        MsgBox( 0, "Color Match", "The pixel color is just as close to black as it is to red." )
    EndIf
EndFunc

Hope that helps,

Don

_____________________________________________________"some people live for the rules, I live for exceptions"Wallpaper Changer - Easily Change Your Windows Wallpaper

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
  • Recently Browsing   0 members

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