Jump to content
Sign in to follow this  

PixelGetColor, Color Codes :)

Recommended Posts


This is a Quick one!

Lets say i want to make the PixelGetColor not to take a exact match.

If i want it to take diffrent Shades of Blue for instance.

Lets say Bluelight gets the Value 100 from PixelGetColor and BlueDark gets 200

I want to take in the whole spectrum of Blue

IF Pixelsearch > 250

Just some very bad, halfhearted example code to make my point more obvious

Is there a list of Color Codes somewhere?

Or can some simple math figure it out how the Color Code gets its numbers?

Or can i even Convert Html color code with the right formula?

Edited by Schoening

Share this post

Link to post
Share on other sites

This may give you a few ideas.

There are other ways of getting the individual colour channel values from a RGB colour.

Opt("MouseCoordMode", 1) ;1=absolute, 0=relative, 2=client
HotKeySet("{ESC}", "Terminate")

Local $exit = 1

While $exit

; TtColXY() Tooltip shows colour, and cursor position relative to screen and window.
Func TtColXY()
    $aPos = MouseGetPos()
    $sColor = "0x" & Hex(PixelGetColor($aPos[0], $aPos[1]), 6)
    $iPosX = ($aPos[0] - 100) * ($aPos[0] > @DesktopWidth * 0.90) + ($aPos[0] <= @DesktopWidth * 0.90) * ($aPos[0] + 3)
    $iPosY = ($aPos[1] - 30) * ($aPos[1] > @DesktopHeight * 0.96) + ($aPos[1] <= @DesktopHeight * 0.96) * ($aPos[1] + 3)
    $Red = Int("0x" & StringRegExpReplace($sColor, "(..)(..)(..)(..)", "\2"))
    $Green = Int("0x" & StringRegExpReplace($sColor, "(..)(..)(..)(..)", "\3"))
    $Blue = Int("0x" & StringRegExpReplace($sColor, "(..)(..)(..)(..)", "\4"))
    If $Blue > $Green And $Blue > $Red Then
        If $Blue > 200 Then $BShade = "Light"
        If $Blue <= 200 Then $BShade = "Dark"
        $BShade = "Nil"

    ToolTip("Color is: " & $sColor & @CRLF & _
            " R:" & $Red & _
            " G:" & $Green & _
            " B:" & $Blue & @CRLF & _
            "Shade of blue - " & $BShade)
EndFunc   ;==>TtColXY

Func Terminate()
    $exit = 0
EndFunc   ;==>Terminate

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  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.