Sign in to follow this  
Followers 0
ExElNeT

Color is Red or Black?

4 posts in this topic

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

Share this post


Link to post
Share on other sites



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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

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