Jump to content
Sign in to follow this  
buzz44

RGB to Hex to RGB /w COLOURS!

Recommended Posts

worked on it for 2 days!! lol.. i suk =( .. but in the end its all good

thanks to all the people that helped .. ie jbed and andre.

will add an "eyedropper" shortly so u can get the colour and dont have to type it in etc.

simple script .... shows the RGB values and the HEX value of a colour ... includes a coloured label so you know wat colour it is!!!! =)

enjoy... open to critisism :lmao:

thx

#include <GuiConstants.au3>
#include "color.au3"
#include-once "kkkk.au3"


Global $A_Red
Global $A_Green
Global $A_Blue
Global $B_Red
Global $B_Green
Global $B_Blue

GuiCreate("MyGUI", 162, 100,(@DesktopWidth-162)/2, (@DesktopHeight-81)/2)

$Input_Red = GuiCtrlCreateInput("0", 10, 24, 40, 20, $ES_NUMBER)
$Input_Green = GuiCtrlCreateInput("0", 60, 24, 40, 20, $ES_NUMBER)
$Input_Blue = GuiCtrlCreateInput("0", 110, 24, 40, 20, $ES_NUMBER)
$Input_Hex = GuiCtrlCreateInput("0x000000", 10, 50, 80, 20)
$Label_Blue = GuiCtrlCreateLabel("Blue", 110, 10, 30, 13)
$Label_Red = GuiCtrlCreateLabel("Red", 10, 10, 40, 11)
$Label_Green = GuiCtrlCreateLabel("Green", 60, 10, 40, 14)
$Label_Colour = GuiCtrlCreateLabel("", 100, 50, 50, 20)
$updown_Red = GUICtrlCreateUpdown($Input_Red,$UDS_ARROWKEYS)
$updown_Blue = GUICtrlCreateUpdown($Input_Blue,$UDS_ARROWKEYS)
$updown_Green = GUICtrlCreateUpdown($Input_Green,$UDS_ARROWKEYS)
$EyeDropper = GUICtrlCreateButton("Eye Dropper", 11, 75, 140,20)

GUICtrlSetPos($Input_Red, 10,25, 40, 20 )
GUICtrlSetPos($Input_Green, 60,25, 40, 20 )
GUICtrlSetPos($Input_Blue, 110,25, 40, 20 )
GUICtrlSetLimit($updown_Red, 255, 0)
GUICtrlSetLimit($updown_Blue, 255, 0)
GUICtrlSetLimit($updown_Green, 255, 0)
GUICtrlSetLimit($Input_Hex, 8, 0)

GuiSetState()

While 1
   WinSetOnTop ( "MyGUI", "",1)
   If StringLen (GUICtrlRead($Input_Hex)) = 0 Then
      GUICtrlSetData($Input_Hex,"0x000000")
   EndIf
   _GetRGB()
   If StringLen (GUICtrlRead($Input_Hex)) = 8 Then
      _GetHex()
   EndIf
   $msg = GUIGetMsg()
   If $msg = $GUI_EVENT_CLOSE Then
      ExitLoop
   EndIf
   If $msg = $EyeDropper Then
      EyeDropper() 
   EndIf
WEnd
Exit

Func _GetHex()
    $Hex_Red = Hex(GUICtrlRead($Input_Red), 2)
    $Hex_Green = Hex(GUICtrlRead($Input_Green), 2)
    $Hex_Blue = Hex(GUICtrlRead($Input_Blue), 2)
    If String($Hex_Red) <> String($A_Red) Or String($Hex_Green) <> String($A_Green) Or String($Hex_Blue) <> String($A_Blue) Then
       $Str_RGB = StringReplace (GUICtrlRead($Input_Hex), 3, $Hex_Red)
       GUICtrlSetData ($Input_Hex, $Str_RGB)
       $Str_RGB = StringReplace (GUICtrlRead($Input_Hex), 5, $Hex_Green)
       GUICtrlSetData ($Input_Hex, $Str_RGB)
       $Str_RGB = StringReplace (GUICtrlRead($Input_Hex), 7, $Hex_Blue)
       GUICtrlSetData ($Input_Hex, $Str_RGB)
       $A_Red = $Hex_Red
       $A_Green = $Hex_Green
       $A_Blue = $Hex_Blue  
    EndIf
    GUICtrlSetBkColor($Label_Colour, GUICtrlRead($Input_Hex))
EndFunc

Func _GetRGB()
   $RGB_Red = _ColorGetRed (GUICtrlRead($Input_Hex))
   $RGB_Green = _ColorGetGreen (GUICtrlRead($Input_Hex))
   $RGB_Blue = _ColorGetBlue (GUICtrlRead($Input_Hex))
   If String($RGB_Red) <> String($B_Red) Or String($RGB_Green) <> String($B_Green) Or String($RGB_Blue) <> String($B_Blue) Then
      GUICtrlSetData ($Input_Red, $RGB_Red)
      GUICtrlSetData ($Input_Green, $RGB_Green)
      GUICtrlSetData ($Input_Blue, $RGB_Blue)
      $B_Red = $RGB_Red
      $B_Green = $RGB_Green
      $B_Blue = $RGB_Blue
      GUICtrlSetBkColor($Label_Colour, GUICtrlRead ($Input_Hex))
   EndIf
EndFunc

Func EyeDropper()
   Do
      $Pos = MouseGetPos()
      $Dec_Colour = PixelGetColor($Pos[0],$Pos[1])
      $Hex_Colour = Hex ($Dec_Colour, 6)
      GUICtrlSetData ($Input_Hex, "0x" & $Hex_Colour)
      GUICtrlSetBkColor($Label_Colour, GUICtrlRead ($Input_Hex))
   Until _IsPressed('01') = 1
EndFunc

Func _IsPressed($hexKey)
   Local $aR
   $hexKey = '0x' & $hexKey
   $aR = DllCall("user32", "int", "GetAsyncKeyState", "int", $hexKey)
   If Not @error And BitAND($aR[0],0x8000) = 0x8000 Then Return 1
   Return 0
EndFunc
Edited by burrup

qq

Share this post


Link to post
Share on other sites

i hate you lol ... pfft i could do that but i dont wanna :lmao: .. its given my some idea but on how to improve mine .. gimme 5 more mins and ill have eye dropper thing + screen magnifier thing


qq

Share this post


Link to post
Share on other sites

k . this know has ... "eye dropper" and can select a colour anywhere the mouse can go =)

#include <GuiConstants.au3>
#include "color.au3"
#include-once "kkkk.au3"


Global $A_Red
Global $A_Green
Global $A_Blue
Global $B_Red
Global $B_Green
Global $B_Blue

GuiCreate("MyGUI", 162, 100,(@DesktopWidth-162)/2, (@DesktopHeight-81)/2)

$Input_Red = GuiCtrlCreateInput("0", 10, 24, 40, 20, $ES_NUMBER)
$Input_Green = GuiCtrlCreateInput("0", 60, 24, 40, 20, $ES_NUMBER)
$Input_Blue = GuiCtrlCreateInput("0", 110, 24, 40, 20, $ES_NUMBER)
$Input_Hex = GuiCtrlCreateInput("0x000000", 10, 50, 80, 20)
$Label_Blue = GuiCtrlCreateLabel("Blue", 110, 10, 30, 13)
$Label_Red = GuiCtrlCreateLabel("Red", 10, 10, 40, 11)
$Label_Green = GuiCtrlCreateLabel("Green", 60, 10, 40, 14)
$Label_Colour = GuiCtrlCreateLabel("", 100, 50, 50, 20)
$updown_Red = GUICtrlCreateUpdown($Input_Red,$UDS_ARROWKEYS)
$updown_Blue = GUICtrlCreateUpdown($Input_Blue,$UDS_ARROWKEYS)
$updown_Green = GUICtrlCreateUpdown($Input_Green,$UDS_ARROWKEYS)
$EyeDropper = GUICtrlCreateButton("Eye Dropper", 11, 75, 140,20)

GUICtrlSetPos($Input_Red, 10,25, 40, 20 )
GUICtrlSetPos($Input_Green, 60,25, 40, 20 )
GUICtrlSetPos($Input_Blue, 110,25, 40, 20 )
GUICtrlSetLimit($updown_Red, 255, 0)
GUICtrlSetLimit($updown_Blue, 255, 0)
GUICtrlSetLimit($updown_Green, 255, 0)
GUICtrlSetLimit($Input_Hex, 8, 0)

GuiSetState()

While 1
   WinSetOnTop ( "MyGUI", "",1)
   If StringLen (GUICtrlRead($Input_Hex)) = 0 Then
      GUICtrlSetData($Input_Hex,"0x000000")
   EndIf
   _GetRGB()
   If StringLen (GUICtrlRead($Input_Hex)) = 8 Then
      _GetHex()
   EndIf
   $msg = GUIGetMsg()
   If $msg = $GUI_EVENT_CLOSE Then
      ExitLoop
   EndIf
   If $msg = $EyeDropper Then
      EyeDropper() 
   EndIf
WEnd
Exit

Func _GetHex()
    $Hex_Red = Hex(GUICtrlRead($Input_Red), 2)
    $Hex_Green = Hex(GUICtrlRead($Input_Green), 2)
    $Hex_Blue = Hex(GUICtrlRead($Input_Blue), 2)
    If String($Hex_Red) <> String($A_Red) Or String($Hex_Green) <> String($A_Green) Or String($Hex_Blue) <> String($A_Blue) Then
       $Str_RGB = StringReplace (GUICtrlRead($Input_Hex), 3, $Hex_Red)
       GUICtrlSetData ($Input_Hex, $Str_RGB)
       $Str_RGB = StringReplace (GUICtrlRead($Input_Hex), 5, $Hex_Green)
       GUICtrlSetData ($Input_Hex, $Str_RGB)
       $Str_RGB = StringReplace (GUICtrlRead($Input_Hex), 7, $Hex_Blue)
       GUICtrlSetData ($Input_Hex, $Str_RGB)
       $A_Red = $Hex_Red
       $A_Green = $Hex_Green
       $A_Blue = $Hex_Blue  
    EndIf
    GUICtrlSetBkColor($Label_Colour, GUICtrlRead($Input_Hex))
EndFunc

Func _GetRGB()
   $RGB_Red = _ColorGetRed (GUICtrlRead($Input_Hex))
   $RGB_Green = _ColorGetGreen (GUICtrlRead($Input_Hex))
   $RGB_Blue = _ColorGetBlue (GUICtrlRead($Input_Hex))
   If String($RGB_Red) <> String($B_Red) Or String($RGB_Green) <> String($B_Green) Or String($RGB_Blue) <> String($B_Blue) Then
      GUICtrlSetData ($Input_Red, $RGB_Red)
      GUICtrlSetData ($Input_Green, $RGB_Green)
      GUICtrlSetData ($Input_Blue, $RGB_Blue)
      $B_Red = $RGB_Red
      $B_Green = $RGB_Green
      $B_Blue = $RGB_Blue
      GUICtrlSetBkColor($Label_Colour, GUICtrlRead ($Input_Hex))
   EndIf
EndFunc

Func EyeDropper()
   Do
      $Pos = MouseGetPos()
      $Dec_Colour = PixelGetColor($Pos[0],$Pos[1])
      $Hex_Colour = Hex ($Dec_Colour, 6)
      GUICtrlSetData ($Input_Hex, "0x" & $Hex_Colour)
      GUICtrlSetBkColor($Label_Colour, GUICtrlRead ($Input_Hex))
   Until _IsPressed('01') = 1
EndFunc

Func _IsPressed($hexKey)
   Local $aR
   $hexKey = '0x' & $hexKey
   $aR = DllCall("user32", "int", "GetAsyncKeyState", "int", $hexKey)
   If Not @error And BitAND($aR[0],0x8000) = 0x8000 Then Return 1
   Return 0
EndFunc
Edited by burrup

qq

Share this post


Link to post
Share on other sites

That's pretty slick man. Thanks for the script!

k . this know has ... "eye dropper" and can select a colour anywhere the mouse can go =)

#include <GuiConstants.au3>
#include "color.au3"

Global $A_Red
Global $A_Green
Global $A_Blue
Global $B_Red
Global $B_Green
Global $B_Blue

GuiCreate("MyGUI", 162, 100,(@DesktopWidth-162)/2, (@DesktopHeight-81)/2)

$Input_Red = GuiCtrlCreateInput("0", 10, 24, 40, 20, $ES_NUMBER)
$Input_Green = GuiCtrlCreateInput("0", 60, 24, 40, 20, $ES_NUMBER)
$Input_Blue = GuiCtrlCreateInput("0", 110, 24, 40, 20, $ES_NUMBER)
$Input_Hex = GuiCtrlCreateInput("0x000000", 10, 50, 80, 20)
$Label_Blue = GuiCtrlCreateLabel("Blue", 110, 10, 30, 13)
$Label_Red = GuiCtrlCreateLabel("Red", 10, 10, 40, 11)
$Label_Green = GuiCtrlCreateLabel("Green", 60, 10, 40, 14)
$Label_Colour = GuiCtrlCreateLabel("", 100, 50, 50, 20)
$updown_Red = GUICtrlCreateUpdown($Input_Red,$UDS_ARROWKEYS)
$updown_Blue = GUICtrlCreateUpdown($Input_Blue,$UDS_ARROWKEYS)
$updown_Green = GUICtrlCreateUpdown($Input_Green,$UDS_ARROWKEYS)
$EyeDropper = GUICtrlCreateButton("Eye Dropper", 11, 75, 140,20)

GUICtrlSetPos($Input_Red, 10,25, 40, 20 )
GUICtrlSetPos($Input_Green, 60,25, 40, 20 )
GUICtrlSetPos($Input_Blue, 110,25, 40, 20 )
GUICtrlSetLimit($updown_Red, 255, 0)
GUICtrlSetLimit($updown_Blue, 255, 0)
GUICtrlSetLimit($updown_Green, 255, 0)

GuiSetState()

While 1
   WinSetOnTop ( "MyGUI", "",1)
    _GetRGB()
    If StringLen (GUICtrlRead($Input_Hex)) = 8 Then
       _GetHex()
    EndIf
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then
       ExitLoop
    EndIf
    If $msg = $EyeDropper Then
       EyeDropper() 
    EndIf
WEnd
Exit

Func _GetHex()
    $Hex_Red = Hex(GUICtrlRead($Input_Red), 2)
    $Hex_Green = Hex(GUICtrlRead($Input_Green), 2)
    $Hex_Blue = Hex(GUICtrlRead($Input_Blue), 2)
    If String($Hex_Red) <> String($A_Red) Or String($Hex_Green) <> String($A_Green) Or String($Hex_Blue) <> String($A_Blue) Then
       $Str_RGB = StringReplace (GUICtrlRead($Input_Hex), 3, $Hex_Red)
       GUICtrlSetData ($Input_Hex, $Str_RGB)
       $Str_RGB = StringReplace (GUICtrlRead($Input_Hex), 5, $Hex_Green)
       GUICtrlSetData ($Input_Hex, $Str_RGB)
       $Str_RGB = StringReplace (GUICtrlRead($Input_Hex), 7, $Hex_Blue)
       GUICtrlSetData ($Input_Hex, $Str_RGB)
       $A_Red = $Hex_Red
       $A_Green = $Hex_Green
       $A_Blue = $Hex_Blue  
    EndIf
    GUICtrlSetBkColor($Label_Colour, GUICtrlRead($Input_Hex))
EndFunc

Func _GetRGB()
   $RGB_Red = _ColorGetRed (GUICtrlRead($Input_Hex))
   $RGB_Green = _ColorGetGreen (GUICtrlRead($Input_Hex))
   $RGB_Blue = _ColorGetBlue (GUICtrlRead($Input_Hex))
   If String($RGB_Red) <> String($B_Red) Or String($RGB_Green) <> String($B_Green) Or String($RGB_Blue) <> String($B_Blue) Then
      GUICtrlSetData ($Input_Red, $RGB_Red)
      GUICtrlSetData ($Input_Green, $RGB_Green)
      GUICtrlSetData ($Input_Blue, $RGB_Blue)
      $B_Red = $RGB_Red
      $B_Green = $RGB_Green
      $B_Blue = $RGB_Blue
      GUICtrlSetBkColor($Label_Colour, GUICtrlRead ($Input_Hex))
   EndIf
EndFunc

Func EyeDropper()
   Do
      $Pos = MouseGetPos()
      $Dec_Colour = PixelGetColor($Pos[0],$Pos[1])
      $Hex_Colour = Hex ($Dec_Colour, 6)
      GUICtrlSetData ($Input_Hex, "0x" & $Hex_Colour)
      GUICtrlSetBkColor($Label_Colour, GUICtrlRead ($Input_Hex))
   Until _IsPressed('01') = 1
EndFunc

Func _IsPressed($hexKey)
   Local $aR
   $hexKey = '0x' & $hexKey
   $aR = DllCall("user32", "int", "GetAsyncKeyState", "int", $hexKey)
   If Not @error And BitAND($aR[0],0x8000) = 0x8000 Then Return 1
   Return 0
EndFunc

<{POST_SNAPBACK}>

Share this post


Link to post
Share on other sites

YAY a compliemnt! .. yeah i thought it might be helpful for me(and other people) .. after looking at that "xdrop" i will add sum new features

>>> sliders

>>> pallete

etc

i orignally done a "sketchpad" in VB using this. except it was more like "paint" .. u could draw a picture and save it to a file .. im not sure if u can do this with autoit.

thx


qq

Share this post


Link to post
Share on other sites
Guest Guidosoft

hmmm. Very interesting. Very interesting indeed. I must take this script to my special laboratory for disection. It contains some coding technoligy that I do not possess.

But that is coooooooool.

Share this post


Link to post
Share on other sites
Guest Guidosoft

=) .. "coding u do not process" ..  do i do the coding wrong o:) ?? .. and sure disect away :lmao:

<{POST_SNAPBACK}>

No no no. You do the coding great. It is just your coding style is beyond me, so it is I who am lacking. This is one I am saying. You are doing good. Edited by Guidosoft

Share this post


Link to post
Share on other sites

YAY! lol .. i thought i was the one who sucked .. j/k =) .. yeah i had sum help from andre and jdeb with the "globals" ... this enabled it so that u could change the HEX and the RGB would change and visvera ...

EDIT : fixed both the codes above so that now if u CUT the Hex out it will not display a hex .... changin codes now .. look above for updated version.


qq

Share this post


Link to post
Share on other sites

this is much smaller than x drop, i will probably use it for making web pages so the colors in my images match up with the colors in my page

btw my mouse always flashes when it is in the window and after i click the eye dropper button the close button doesn't work until i click it again

edit: my mouse doesn't flash anymore no idea why :lmao:

Edited by Xenogis

[font="Times"] If anyone remembers me, I am back. Maybe to stay, maybe not.----------------------------------------------------------------------------------------------------------[/font][font="Times"]Things I am proud of: Pong! in AutoIt | SearchbarMy website: F.R.I.E.S.A little website that is trying to get started: http://thepiratelounge.net/ (not mine)[/font][font="Times"] ----------------------------------------------------------------------------------------------------------[/font][font="Arial"]The newbies need to stop stealing avatars!!! It is confusing!![/font]

Share this post


Link to post
Share on other sites

this is much smaller than x drop, i will probably use it for making web pages so the colors in my images match up with the colors in my page

btw my mouse always flashes when it is in the window and after i click the eye dropper button the close button doesn't work until i click it again

edit: my mouse doesn't flash anymore no idea why  :lmao:

<{POST_SNAPBACK}>

yeah it is a bit smaller ... currently ... about the mouse thing .. idk why that happens.. it works fine with mine and glad to know that it stopped lol ..

with the eyedropper... i also noticed that problem in a debugging stage ... originally if u clicked the eyedropper button and then clicked exit it would do nothing .. u would have to click it 2-3 times to get it to exit.. i tried every different possile i knew to change ... i put the "If $msg = $eyedropper Then Exit" at the top bottom in the middle .. in the eye dropper function .. and the best i could do was to get the colour of the exit button ... im also working on the eye dropper function that doesnt actually click .. it will get the colour beneath the mouse but wont actually click in a window/desktop ... like if there is a button beneath the mouse it wont click the button but when u click the mouse button it will get the colour beneath the mouse ...

i have now worked alot on my script to improve it .. its no about twice the size and includes

>>> RGB updown inputs

>>> Hex input

>>> Displays colour preview

>>> has RGB sliders

>>> colour palette

>>> the windows advanced colour palette

>>> coming soon ... magnifier for eye dropper. so u can pik colours easier ..

thx


qq

Share this post


Link to post
Share on other sites

Very nice burrup! I will be using this a lot. :lmao:

Is it possible that when the eyedropper is selected, the cursor changes to the crosshair cursor, which is a standard cursor in windows?

Edited by steveR

AutoIt3 online docs Use it... Know it... Live it...MSDN libraryglobal Help and SupportWindows: Just another pane in the glass.

Share this post


Link to post
Share on other sites

Thanks! im glad people like it in its un-finished version lol.. the final will probably be done by tonight =) .. just gotta fix a couple bugs etc and then ill hit it up :lmao:... be sure to check for newer versions .. thx for compliment

edit : yes .. that is one of the things i will be changin in the final version .. when u click eyedropper it will change the curcor to a different one =).

Edited by burrup

qq

Share this post


Link to post
Share on other sites
Guest Guidosoft

Burrup, do you have a web page?

If you keep on making scripts like these you should make a web page too put them all on. Your script are pretty usefull. You could use the public file area or freewebs.com or geocities or w/e.

Are you new though? Cause I haven't seen you on the forum prior to this post.

Share this post


Link to post
Share on other sites

yeah sorta lol ... i used to post when i first joined the forum.. then i stopped autoit and thus stopped posting .. now im back lol ...yeah i would like to do that lol .. but b4 i do i really when finish it.. i could probably get it done by tonight but i gotta figure out this "ChooseColourDialog" thing .. any help =) .. when i finish i will add it to my user file thing =)


qq

Share this post


Link to post
Share on other sites
Guest Guidosoft

yeah sorta lol ... i used to post when i first joined the forum.. then i stopped autoit and thus stopped posting .. now im back lol ...yeah i would like to do that lol .. but b4 i do i really when finish it.. i could probably get it done by tonight but i gotta figure out this "ChooseColourDialog" thing .. any help =) .. when i finish i will add it to my user file thing =)

<{POST_SNAPBACK}>

oh ok. lol. You been checking this topic all day lol. We have that in common. We keep cheking our topics to see if anyone replies. And hours go by and we don't even notice. lol.

Share this post


Link to post
Share on other sites

true that lol .. each time i think i rdy to realise the final version i always think of a new idea and have to add it lol .. after this last bit i SWEAR ill finish with it lol ... only problem im having is the ScreenMagnidier thing .. im trying to use the below attachemnt file ... i want it to fun that file or sumthing when i click ona button . but i have no diea how to = (..


qq

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...