Jump to content

Color Picker


dv8
 Share

Recommended Posts

Here it is. :)

I hope it'll be useful.

#include <GUIConstants.au3>

Opt("GUIOnEventMode", 1) ; Change to OnEvent mode 
$mainwindow = GUICreate("ColorPick", 100, 155,-1,-1,$WS_SYSMENU)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")

$labelR = GUICtrlCreateLabel ("R", 5,10,10,30)
GUICtrlSetColor(-1,0xFF0000)
GUICtrlSetFont (-1,9, 600)
$input1 = GUICtrlCreateInput ("0",15,5,40,20,BITOR($WS_TABSTOP,$ES_NUMBER))
$updown1 = GUICtrlCreateUpdown($input1,BITOR($UDS_ARROWKEYS,$UDS_WRAP))
GUICtrlSetLimit(-1,255,0)
GUICtrlSetOnEvent($input1, "_slider1")
$label1 = GUICtrlCreateLabel ("", 60,5,20,20)
GUICtrlSetBkColor(-1,0x000000)
$label1_hv = GUICtrlCreateLabel ("00", 85,10,15,15)

$labelG = GUICtrlCreateLabel ("G", 5,35,10,30)
GUICtrlSetColor(-1,0x00FF00)
GUICtrlSetFont (-1,9, 600)
$input2 = GUICtrlCreateInput ("0",15,30,40,20,BITOR($WS_TABSTOP,$ES_NUMBER))
$updown2 = GUICtrlCreateUpdown($input2,BITOR($UDS_ARROWKEYS,$UDS_WRAP))
GUICtrlSetLimit(-1,255,0)
GUICtrlSetOnEvent($input2, "_slider2")
$label2 = GUICtrlCreateLabel ("", 60,30,20,20)
GUICtrlSetBkColor(-1,0x000000)
$label2_hv = GUICtrlCreateLabel ("00", 85,35,15,15)

$labelB = GUICtrlCreateLabel ("B", 5,60,10,30)
GUICtrlSetColor(-1,0x0000FF)
GUICtrlSetFont (-1,9, 600)
$input3 = GUICtrlCreateInput ("0",15,55,40,20,BITOR($WS_TABSTOP,$ES_NUMBER))
$updown3 = GUICtrlCreateUpdown($input3,BITOR($UDS_ARROWKEYS,$UDS_WRAP))
GUICtrlSetLimit(-1,255,0)
GUICtrlSetOnEvent($input3, "_slider3")
$label3 = GUICtrlCreateLabel ("", 60,55,20,20)
GUICtrlSetBkColor(-1,0x000000)
$label3_hv = GUICtrlCreateLabel ("00", 85,60,15,15)

$label4 = GUICtrlCreateLabel ("", 5,80,95,20)
GUICtrlSetBkColor(-1, "0x"&hex(GUICtrlRead($input1),2)&hex(GUICtrlRead($input2),2)&hex(GUICtrlRead($input3),2))

$hex = GUICtrlCreateInput (hex(GUICtrlRead($input1),2)&hex(GUICtrlRead($input2),2)&hex(GUICtrlRead($input3),2), 25,105,50,20,BITOR($ES_READONLY,$WS_TABSTOP,$ES_CENTER))

GUISetState(@SW_SHOW)

While 1
  Sleep(100)
WEnd

Func _slider1()
  GUICtrlSetBkColor($label1, "0x"&hex(GUICtrlRead(@GUI_CTRLID),2)&"0000")
  GUICtrlSetData($label1_hv,hex(GUICtrlRead(@GUI_CTRLID),2))
  GUICtrlSetData($hex,hex(GUICtrlRead($input1),2)&hex(GUICtrlRead($input2),2)&hex(GUICtrlRead($input3),2))
  GUICtrlSetBkColor($label4, "0x"&hex(GUICtrlRead($input1),2)&hex(GUICtrlRead($input2),2)&hex(GUICtrlRead($input3),2))
EndFunc

Func _slider2()
  GUICtrlSetBkColor($label2, "0x00"&hex(GUICtrlRead(@GUI_CTRLID),2)&"00")
  GUICtrlSetData($label2_hv,hex(GUICtrlRead(@GUI_CTRLID),2))
  GUICtrlSetData($hex,hex(GUICtrlRead($input1),2)&hex(GUICtrlRead($input2),2)&hex(GUICtrlRead($input3),2))
  GUICtrlSetBkColor($label4, "0x"&hex(GUICtrlRead($input1),2)&hex(GUICtrlRead($input2),2)&hex(GUICtrlRead($input3),2))
EndFunc

Func _slider3()
  GUICtrlSetBkColor($label3, "0x0000"&hex(GUICtrlRead(@GUI_CTRLID),2))
  GUICtrlSetData($label3_hv,hex(GUICtrlRead(@GUI_CTRLID),2))
  GUICtrlSetData($hex,hex(GUICtrlRead($input1),2)&hex(GUICtrlRead($input2),2)&hex(GUICtrlRead($input3),2))
  GUICtrlSetBkColor($label4, "0x"&hex(GUICtrlRead($input1),2)&hex(GUICtrlRead($input2),2)&hex(GUICtrlRead($input3),2))
EndFunc

Func CLOSEClicked()
      Exit
EndFunc
Link to comment
Share on other sites

  • Moderators

Really nice job dv8!

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • Moderators

10x! Glad you like it.

I tried to run it with the standard AutiIt (not the latest beta). It runs without errors, but the colors don't change.

I find this a little bit strange.

I would compare my 2 #include <GUIConstant.au3>'s with one another to make sure that the constants I'm using are the same, I also don't know/remember if Hex() was part of the original release, but I imagine it would have thrown you an error by now.

I only use/have Beta installed now, as It does everything that the release does and a tad more.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

I would compare my 2 #include <GUIConstant.au3>'s with one another to make sure that the constants I'm using are the same, I also don't know/remember if Hex() was part of the original release, but I imagine it would have thrown you an error by now.

I only use/have Beta installed now, as It does everything that the release does and a tad more.

I guess, it's the HEX() function that's causing the problem. The only reason i wanted to use the alpha version is that the compiled program is 123KB (203KB - compiled with the beta).

Link to comment
Share on other sites

  • Moderators

I guess, it's the HEX() function that's causing the problem. The only reason i wanted to use the alpha version is that the compiled program is 123KB (203KB - compiled with the beta).

Sounds to me that the #include files are smaller in the release to get that kind of kb setting, did you compare the 2?

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • Moderators

The included GUIConstants files are matching completely.

Ok :) ... Maybe the new UPX 2.0 packer is creating the extra size? I don't know lol.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

there was a nice one from thatsgreat here ( today)

I definitely like Thatsgreat's sliders over the "updowns", but I do like dv8's composite color patch. Now if we can get them to pop up inside SciTE when you need to choose a color!! :)
...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format
Link to comment
Share on other sites

I definitely like Thatsgreat's sliders over the "updowns", but I do like dv8's composite color patch.

I made it with sliders at first, but didn't like that when you slide it the color didn't change until you let go the slider.

And another advantages of the updowns is that they are smaller and you can input the values yourself. :)

Going from updowns to sliders is easy, just a matter of changeing a fiew lines and coordinates.

Now if we can get them to pop up inside SciTE when you need to choose a color!! :D

That was the purpose of this script. I'm useing ConText for programming. It's great freeware editor, but doesn't have a color picker. So I made my own and call it useing the customizable "User Exec Keys" :(
Link to comment
Share on other sites

I made it with sliders at first, but didn't like that when you slide it the color didn't change until you let go the slider.

And another advantages of the updowns is that they are smaller and you can input the values yourself. :)

Going from updowns to sliders is easy, just a matter of changeing a fiew lines and coordinates.

That was the purpose of this script. I'm useing ConText for programming. It's great freeware editor, but doesn't have a color picker. So I made my own and call it useing the customizable "User Exec Keys" :(

uhmmmm mine changes its just cuz urs calls functions mine i just put in a continually checking loop

Link to comment
Share on other sites

added in quick color patches could only think of doing it with adlibenable

#include <GUIConstants.au3>
$GUI = GUICreate("Color Chooser", 579, 289, 192, 125)
GUISetBkColor(0xF1EFE2)
$color1 = GUICtrlCreateLabel("", 24, 16, 84, 84)
GUICtrlSetBkColor(-1, 0xF1EFE2)
$color2 = GUICtrlCreateLabel("", 136, 16, 84, 84)
GUICtrlSetBkColor(-1, 0xF1EFE2)
$color3 = GUICtrlCreateLabel("", 248, 16, 84, 84)
GUICtrlSetBkColor(-1, 0xF1EFE2)
$color4 = GUICtrlCreateLabel("", 360, 16, 84, 84)
GUICtrlSetBkColor(-1, 0xF1EFE2)
$color5 = GUICtrlCreateLabel("", 472, 16, 84, 84)
GUICtrlSetBkColor(-1, 0xF1EFE2)
$choose1 = GUICtrlCreateRadio("Color 1", 24, 112, 65, 17)
GUICtrlSetBkColor(-1, 0xF1EFE2)
$choose2 = GUICtrlCreateRadio("Color 2", 136, 112, 65, 17)
GUICtrlSetBkColor(-1, 0xF1EFE2)
$choose3 = GUICtrlCreateRadio("Color 3", 248, 112, 65, 17)
GUICtrlSetBkColor(-1, 0xF1EFE2)
$choose4 = GUICtrlCreateRadio("Color 4", 360, 112, 65, 17)
GUICtrlSetBkColor(-1, 0xF1EFE2)
$choose5 = GUICtrlCreateRadio("Color 5", 472, 112, 65, 17)
GUICtrlSetBkColor(-1, 0xF1EFE2)
$input1 = GUICtrlCreateInput("", 16, 136, 81, 21, -1, $WS_EX_CLIENTEDGE)
$input2 = GUICtrlCreateInput("", 128, 136, 81, 21, -1, $WS_EX_CLIENTEDGE)
$input3 = GUICtrlCreateInput("", 248, 136, 81, 21, -1, $WS_EX_CLIENTEDGE)
$input4 = GUICtrlCreateInput("", 352, 136, 81, 21, -1, $WS_EX_CLIENTEDGE)
$input5 = GUICtrlCreateInput("", 464, 136, 81, 21, -1, $WS_EX_CLIENTEDGE)
GUICtrlCreateLabel("Red", 16, 192, 24, 17)
GUICtrlSetBkColor(-1, 0xF1EFE2)
GUICtrlCreateLabel("Green", 16, 216, 33, 17)
GUICtrlSetBkColor(-1, 0xF1EFE2)
GUICtrlCreateLabel("Blue", 16, 240, 25, 17)
GUICtrlSetBkColor(-1, 0xF1EFE2)
$Red = GUICtrlCreateSlider(56, 192, 462, 21)
GUICtrlSetLimit(-1,255,0)
$r = GUICtrlCreateLabel("",530,192,20,20)
$Green = GUICtrlCreateSlider(56, 216, 462, 21)
GUICtrlSetLimit(-1,255,0)
$g = GUICtrlCreateLabel("",530,216,20,20)
$Blue = GUICtrlCreateSlider(56, 240, 462, 21)
GUICtrlSetLimit(-1,255,0)
$b = GUICtrlCreateLabel("",530,240,20,20)
GUISetState(@SW_SHOW)
Red()
Green()
Blue()
WHile 1
$msg = GUIGetMsg()
If $msg = $Red Then
AdlibEnable("Red",150)
ElseIf $msg = $Green Then
AdlibEnable("Green",150)
ElseIf $msg = $Blue Then
AdlibEnable("Blue",150)
EndIf
If $msg = $GUI_EVENT_CLOSE Then Exit
If GUICtrlRead($choose1) = $GUI_CHECKED Then
    GUICtrlSetBkColor($color1,"0x" & Hex(GUICtrlRead($Red),2) & Hex(GUICtrlRead($Green),2) & Hex(GUICtrlRead($Blue),2))
    GUICtrlSetData($input1,"0x" & Hex(GUICtrlRead($Red),2) & Hex(GUICtrlRead($Green),2) & Hex(GUICtrlRead($Blue),2))
ElseIf GUICtrlRead($choose2) = $GUI_CHECKED Then
    GUICtrlSetBkColor($color2,"0x" & Hex(GUICtrlRead($Red),2) & Hex(GUICtrlRead($Green),2) & Hex(GUICtrlRead($Blue),2))
    GUICtrlSetData($input2,"0x" & Hex(GUICtrlRead($Red),2) & Hex(GUICtrlRead($Green),2) & Hex(GUICtrlRead($Blue),2))
ElseIf GUICtrlRead($choose3) = $GUI_CHECKED Then
    GUICtrlSetBkColor($color3,"0x" & Hex(GUICtrlRead($Red),2) & Hex(GUICtrlRead($Green),2) & Hex(GUICtrlRead($Blue),2))
    GUICtrlSetData($input3,"0x" & Hex(GUICtrlRead($Red),2) & Hex(GUICtrlRead($Green),2) & Hex(GUICtrlRead($Blue),2))
ElseIf GUICtrlRead($choose4) = $GUI_CHECKED Then
    GUICtrlSetBkColor($color4,"0x" & Hex(GUICtrlRead($Red),2) & Hex(GUICtrlRead($Green),2) & Hex(GUICtrlRead($Blue),2))
    GUICtrlSetData($input4,"0x" & Hex(GUICtrlRead($Red),2) & Hex(GUICtrlRead($Green),2) & Hex(GUICtrlRead($Blue),2))
ElseIf GUICtrlRead($choose5) = $GUI_CHECKED Then
    GUICtrlSetBkColor($color5,"0x" & Hex(GUICtrlRead($Red),2) & Hex(GUICtrlRead($Green),2) & Hex(GUICtrlRead($Blue),2))
    GUICtrlSetData($input5,"0x" & Hex(GUICtrlRead($Red),2) & Hex(GUICtrlRead($Green),2) & Hex(GUICtrlRead($Blue),2))
EndIf
WEnd


Func Red()
GUICtrlSetBkColor($r,"0x" & Hex(GUICtrlRead($Red),2) & "0000")
EndFunc
Func Green()
    GUICtrlSetBkColor($g,"0x" & "00" & Hex(GUICtrlRead($Green),2) & "00")
EndFunc
Func Blue()
    GUICtrlSetBkColor($b,"0x" & "0000" & Hex(GUICtrlRead($Blue),2))
EndFunc
Link to comment
Share on other sites

  • 5 weeks later...

Did not update the color patches for me.

added in quick color patches could only think of doing it with adlibenable

Edit1: autoit bbcode tags ignored so changed to code tag instead

Edit2: change if - then's to switch and select. modified code so could copy input box data.

Edit3: Moved code to seperate reply.

Edited by eltorro
Link to comment
Share on other sites

However, it works fine now with the following.

#include <GUIConstants.au3>
    $GUI = GUICreate("Color Chooser", 579, 289, 192, 125)
    GUISetBkColor(0xF1EFE2)
    $color1 = GUICtrlCreateLabel("", 24, 16, 84, 84)
    GUICtrlSetBkColor(-1, 0xF1EFE2)
    $color2 = GUICtrlCreateLabel("", 136, 16, 84, 84)
    GUICtrlSetBkColor(-1, 0xF1EFE2)
    $color3 = GUICtrlCreateLabel("", 248, 16, 84, 84)
    GUICtrlSetBkColor(-1, 0xF1EFE2)
    $color4 = GUICtrlCreateLabel("", 360, 16, 84, 84)
    GUICtrlSetBkColor(-1, 0xF1EFE2)
    $color5 = GUICtrlCreateLabel("", 472, 16, 84, 84)
    GUICtrlSetBkColor(-1, 0xF1EFE2)
    $choose1 = GUICtrlCreateRadio("Color 1", 24, 112, 65, 17)
    GUICtrlSetBkColor(-1, 0xF1EFE2)
    $choose2 = GUICtrlCreateRadio("Color 2", 136, 112, 65, 17)
    GUICtrlSetBkColor(-1, 0xF1EFE2)
    $choose3 = GUICtrlCreateRadio("Color 3", 248, 112, 65, 17)
    GUICtrlSetBkColor(-1, 0xF1EFE2)
    $choose4 = GUICtrlCreateRadio("Color 4", 360, 112, 65, 17)
    GUICtrlSetBkColor(-1, 0xF1EFE2)
    $choose5 = GUICtrlCreateRadio("Color 5", 472, 112, 65, 17)
    GUICtrlSetBkColor(-1, 0xF1EFE2)
    $input1 = GUICtrlCreateInput("", 16, 136, 81, 21, -1, $WS_EX_CLIENTEDGE)
    $input2 = GUICtrlCreateInput("", 128, 136, 81, 21, -1, $WS_EX_CLIENTEDGE)
    $input3 = GUICtrlCreateInput("", 248, 136, 81, 21, -1, $WS_EX_CLIENTEDGE)
    $input4 = GUICtrlCreateInput("", 352, 136, 81, 21, -1, $WS_EX_CLIENTEDGE)
    $input5 = GUICtrlCreateInput("", 464, 136, 81, 21, -1, $WS_EX_CLIENTEDGE)
    GUICtrlCreateLabel("Red", 16, 192, 24, 17)
    GUICtrlSetBkColor(-1, 0xF1EFE2)
    GUICtrlCreateLabel("Green", 16, 216, 33, 17)
    GUICtrlSetBkColor(-1, 0xF1EFE2)
    GUICtrlCreateLabel("Blue", 16, 240, 25, 17)
    GUICtrlSetBkColor(-1, 0xF1EFE2)
    $Red = GUICtrlCreateSlider(56, 192, 462, 21)
    GUICtrlSetLimit(-1,255,0)
    $r = GUICtrlCreateLabel("",530,192,20,20)
    $Green = GUICtrlCreateSlider(56, 216, 462, 21)
    GUICtrlSetLimit(-1,255,0)
    $g = GUICtrlCreateLabel("",530,216,20,20)
    $Blue = GUICtrlCreateSlider(56, 240, 462, 21)
    GUICtrlSetLimit(-1,255,0)
    $b = GUICtrlCreateLabel("",530,240,20,20)
    GUISetState(@SW_SHOW)
    Red()
    Green()
    Blue()
    WHile 1
    $msg = GUIGetMsg()
        Switch $msg 
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Red
            Red()
        Case $Blue
            Blue()
        Case $Green
            Green()
        Case Else
            Select 
                Case  GUICtrlRead($choose1) = $GUI_CHECKED 
                    If GuiCtrlRead($input1) <> _RgbHex() then
                        GUICtrlSetBkColor($color1, _RgbHex())
                        GUICtrlSetData($input1, _RgbHex())
                    EndIf
                Case GUICtrlRead($choose2) = $GUI_CHECKED
                    If GuiCtrlRead($input2) <> _RgbHex() then
                        GUICtrlSetBkColor($color2, _RgbHex())
                        GUICtrlSetData($input2, _RgbHex())
                    EndIf
                Case GUICtrlRead($choose3) = $GUI_CHECKED
                    If GuiCtrlRead($input3) <> _RgbHex() then
                        GUICtrlSetBkColor($color3, _RgbHex())
                        GUICtrlSetData($input3, _RgbHex())
                    EndIf
                Case GUICtrlRead($choose4) = $GUI_CHECKED
                    If GuiCtrlRead($input4) <> _RgbHex() then
                        GUICtrlSetBkColor($color4, _RgbHex())
                        GUICtrlSetData($input4, _RgbHex())
                    EndIf
                Case GUICtrlRead($choose5) = $GUI_CHECKED 
                    If GuiCtrlRead($input5) <> _RgbHex() then
                        GUICtrlSetBkColor($color5, _RgbHex())
                        GUICtrlSetData($input5, _RgbHex())
                    EndIf
            EndSelect
        EndSwitch
    WEnd
    
    Func _RgbHex()
        Return "0x" & Hex(GUICtrlRead($Red),2) & Hex(GUICtrlRead($Green),2) & Hex(GUICtrlRead($Blue),2)
    EndFunc
    Func Red()
    GUICtrlSetBkColor($r,"0x" & Hex(GUICtrlRead($Red),2) & "0000")
    EndFunc
    Func Green()
        GUICtrlSetBkColor($g,"0x" & "00" & Hex(GUICtrlRead($Green),2) & "00")
    EndFunc
    Func Blue()
        GUICtrlSetBkColor($b,"0x" & "0000" & Hex(GUICtrlRead($Blue),2))
    EndFunc
Link to comment
Share on other sites

Nice script :D

That's why i made a while ago:

#include <GUIConstants.au3>

HotKeySet("{ESC}", "Quit")
HotKeySet("{F5}", "F5")
HotKeySet("{F6}", "F6")

MsgBox(0,"Copyright:","This Program Was Made by FaNtA" & @LF & @LF & "Esc to exit" & @LF &"F5 To Get RGB Code" & @LF &"F6 To Get Hexcode")

Global $GUI_Pixel[400]
Global $GUI = GUICreate("Preview",80,80,0,0,$WS_POPUP+$WS_BORDER,$WS_EX_TOPMOST)
Global $LastPos[2] = [0,0]

$label = GUICtrlCreateLabel("",0,0,80,80)
$label2 = GUICtrlCreateLabel("",25,35,40,15)
GUISetState(@SW_SHOW)

    #region <Making the Label>
    $MousePos = MouseGetPos()
    GUICtrlSetBkColor($label,PixelGetColor($MousePos[0],$MousePos[1]))
        If Dec(PixelGetColor($mousePos[0],$MousePos[1])) < Dec(0x7F7F7F) Then
    GUICtrlSetData($label2,StringTrimLeft(Hex(PixelGetColor($MousePos[0],$MousePos[1])),2))
    GUICtrlSetColor(-1,0xffFFFF)
    GuiCtrlSetBkColor($label2,$GUI_BKCOLOR_TRANSPARENT)
        Else
    GUICtrlSetData($label2,StringTrimLeft(Hex(PixelGetColor($MousePos[0],$MousePos[1])),2))
    GUICtrlSetColor(-1,0x000000)
    GuiCtrlSetBkColor($label2,$GUI_BKCOLOR_TRANSPARENT)
        EndIf
    #endregion

While 1
    $MousePos = MouseGetPos()

    If ($LastPos[0] <> $MousePos[0] Or $LastPos[1] <> $MousePos[1]) Then
        WinMove("Preview","",$MousePos[0]+15,$MousePos[1])
        $LastPos[0] = $MousePos[0]
        $LastPos[1] = $MousePos[1]
    #region <Making the Label>
    $MousePos = MouseGetPos()
    GUICtrlSetBkColor($label,PixelGetColor($MousePos[0],$MousePos[1]))
        If Dec(PixelGetColor($mousePos[0],$MousePos[1])) < Dec(0x7F7F7F) Then
    GUICtrlSetData($label2,StringTrimLeft(Hex(PixelGetColor($MousePos[0],$MousePos[1])),2))
    GUICtrlSetColor(-1,0xffFFFF)
    GuiCtrlSetBkColor($label2,$GUI_BKCOLOR_TRANSPARENT)
        Else
    GUICtrlSetData($label2,StringTrimLeft(Hex(PixelGetColor($MousePos[0],$MousePos[1])),2))
    GUICtrlSetColor(-1,0x000000)
    GuiCtrlSetBkColor($label2,$GUI_BKCOLOR_TRANSPARENT)
        EndIf
    #endregion
    EndIf
    
    Sleep(10)
WEnd

Func Quit()
    Exit
EndFunc

Func F5()
    $MousePos = MouseGetPos()
    ClipPut("("& Dec(StringMid(Hex(PixelGetColor($MousePos[0],$MousePos[1])),3,2)) &","& _
    Dec(StringMid(Hex(PixelGetColor($MousePos[0],$MousePos[1])),5,2)) &","& _
    Dec(StringMid(Hex(PixelGetColor($MousePos[0],$MousePos[1])),7,2)) &")")
    ToolTip("RGB-Code successfully saved into the Clipboard")
EndFunc

Func F6()
    $MousePos = MouseGetPos()
    ClipPut(StringTrimLeft(Hex(PixelGetColor($MousePos[0],$MousePos[1])),2))
    ToolTip("Hexcode successfully saved into the Clipboard")
EndFunc
Edited by XxXFaNtA
Link to comment
Share on other sites

  • 7 months later...

I made a update to the original script:

#include <GUIConstants.au3>
$filemake = FileOpen(@ScriptDir&"/bin/color.ini",9)
FileClose($filemake)
Opt("GUIOnEventMode", 1) ; Change to OnEvent mode
$mainwindow = GUICreate("ColorPicker by Dv8  ..................enhancements by Volly", 510, 155,-1,-1,$WS_SYSMENU)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")

$labelR = GUICtrlCreateLabel ("R", 3,7,10,30)
GUICtrlSetColor(-1,0xFF0000)
GUICtrlSetFont (-1,9, 600)
$input1 = GUICtrlCreateInput ("0",15,5,40,20,BITOR($WS_TABSTOP,$ES_NUMBER))
$updown1 = GUICtrlCreateUpdown($input1,BITOR($UDS_ARROWKEYS,$UDS_WRAP))
GUICtrlSetLimit(-1,255,0)
GUICtrlSetOnEvent($input1, "_slider1")
$label1 = GUICtrlCreateLabel ("", 60,5,20,20)
GUICtrlSetBkColor(-1,0x000000)
$label1_hv = GUICtrlCreateLabel ("00", 85,10,15,15)

$labelG = GUICtrlCreateLabel ("G", 3,33,10,30)
GUICtrlSetColor(-1,0x009600)
GUICtrlSetFont (-1,9, 600)
$input2 = GUICtrlCreateInput ("0",15,30,40,20,BITOR($WS_TABSTOP,$ES_NUMBER))
$updown2 = GUICtrlCreateUpdown($input2,BITOR($UDS_ARROWKEYS,$UDS_WRAP))
GUICtrlSetLimit(-1,255,0)
GUICtrlSetOnEvent($input2, "_slider2")
$label2 = GUICtrlCreateLabel ("", 60,30,20,20)
GUICtrlSetBkColor(-1,0x000000)
$label2_hv = GUICtrlCreateLabel ("00", 85,35,15,15)

$labelB = GUICtrlCreateLabel ("B", 3,57,10,30)
GUICtrlSetColor(-1,0x0000FF)
GUICtrlSetFont (-1,9, 600)
$input3 = GUICtrlCreateInput ("0",15,55,40,20,BITOR($WS_TABSTOP,$ES_NUMBER))
$updown3 = GUICtrlCreateUpdown($input3,BITOR($UDS_ARROWKEYS,$UDS_WRAP))
GUICtrlSetLimit(-1,255,0)
GUICtrlSetOnEvent($input3, "_slider3")
$label3 = GUICtrlCreateLabel ("", 60,55,20,20)
GUICtrlSetBkColor(-1,0x000000)
$label3_hv = GUICtrlCreateLabel ("00", 85,60,15,15)

$label4 = GUICtrlCreateLabel ("", 12,80,80,20)
GUICtrlSetBkColor(-1, "0x"&hex(GUICtrlRead($input1),2)&hex(GUICtrlRead($input2),2)&hex(GUICtrlRead($input3),2))

$hex = GUICtrlCreateInput (hex(GUICtrlRead($input1),2)&hex(GUICtrlRead($input2),2)&hex(GUICtrlRead($input3),2), 12,105,80,20,BITOR($ES_READONLY,$WS_TABSTOP,$ES_CENTER))
GUICtrlSetData($hex,"0x"&hex(GUICtrlRead($input1),2)&hex(GUICtrlRead($input2),2)&hex(GUICtrlRead($input3),2))

$label_15 = GUICtrlCreateLabel ("", 120,3,70,70,$SS_SUNKEN)
GUICtrlSetBkColor($label_15, IniRead(@ScriptDir&"/bin/color.ini", "color", 1, ""))
$button_16 = GUICtrlCreateButton("Set", 135, 80, 40, 20)
GUICtrlSetOnEvent($button_16, "_set1")
$button_17 = GUICtrlCreateButton("To Clipboard", 120, 105, 70, 20)
GUICtrlSetOnEvent($button_17, "_clip1")

$label_18 = GUICtrlCreateLabel ("", 220,3,70,70,$SS_SUNKEN)
GUICtrlSetBkColor($label_18, IniRead(@ScriptDir&"/bin/color.ini", "color", 2, "")) 
$button_19 = GUICtrlCreateButton("Set", 235, 80, 40, 20)
GUICtrlSetOnEvent($button_19, "_set2")
$button_20 = GUICtrlCreateButton("To Clipboard", 220, 105, 70, 20)
GUICtrlSetOnEvent($button_20, "_clip2")

$label_21 = GUICtrlCreateLabel ("", 320,3,70,70,$SS_SUNKEN)
GUICtrlSetBkColor($label_21, IniRead(@ScriptDir&"/bin/color.ini", "color", 3, "")) 
$button_22 = GUICtrlCreateButton("Set", 335, 80, 40, 20)
GUICtrlSetOnEvent($button_22, "_set3")
$button_23 = GUICtrlCreateButton("To Clipboard", 320, 105, 70, 20)
GUICtrlSetOnEvent($button_23, "_clip3")

$label_24 = GUICtrlCreateLabel ("", 420,3,70,70,$SS_SUNKEN)
GUICtrlSetBkColor($label_24, IniRead(@ScriptDir&"/bin/color.ini", "color", 4, "")) 
$button_25 = GUICtrlCreateButton("Set", 435, 80, 40, 20)
GUICtrlSetOnEvent($button_25, "_set4")
$button_26 = GUICtrlCreateButton("To Clipboard", 420, 105, 70, 20)
GUICtrlSetOnEvent($button_26, "_clip4")

GUISetState(@SW_SHOW)

While 1
  Sleep(100)
WEnd

Func _set1()
    GUICtrlSetBkColor($label_15, "0x"&hex(GUICtrlRead($input1),2)&hex(GUICtrlRead($input2),2)&hex(GUICtrlRead($input3),2))
    IniWrite(@ScriptDir&"/bin/color.ini", "color", 1, GUICtrlRead($hex))
EndFunc

Func _clip1()
    clipput(IniRead(@ScriptDir&"/bin/color.ini", "color", 1, ""))
EndFunc

Func _set2()
    GUICtrlSetBkColor($label_18, "0x"&hex(GUICtrlRead($input1),2)&hex(GUICtrlRead($input2),2)&hex(GUICtrlRead($input3),2))
    IniWrite(@ScriptDir&"/bin/color.ini", "color", 2, GUICtrlRead($hex))
EndFunc

Func _clip2()
    clipput(IniRead(@ScriptDir&"/bin/color.ini", "color", 2, ""))
EndFunc

Func _set3()
    GUICtrlSetBkColor($label_21, "0x"&hex(GUICtrlRead($input1),2)&hex(GUICtrlRead($input2),2)&hex(GUICtrlRead($input3),2))
    IniWrite(@ScriptDir&"/bin/color.ini", "color", 3, GUICtrlRead($hex))
EndFunc

Func _clip3()
    clipput(IniRead(@ScriptDir&"/bin/color.ini", "color", 3, ""))
EndFunc

Func _set4()
    GUICtrlSetBkColor($label_24, "0x"&hex(GUICtrlRead($input1),2)&hex(GUICtrlRead($input2),2)&hex(GUICtrlRead($input3),2))
    IniWrite(@ScriptDir&"/bin/color.ini", "color", 4, GUICtrlRead($hex))
EndFunc

Func _clip4()
    clipput(IniRead(@ScriptDir&"/bin/color.ini", "color", 4, ""))
EndFunc

Func _slider1()
  GUICtrlSetBkColor($label1, "0x"&hex(GUICtrlRead(@GUI_CTRLID),2)&"0000")
  GUICtrlSetData($label1_hv,hex(GUICtrlRead(@GUI_CTRLID),2))
  GUICtrlSetData($hex,"0x"&hex(GUICtrlRead($input1),2)&hex(GUICtrlRead($input2),2)&hex(GUICtrlRead($input3),2))
  GUICtrlSetBkColor($label4, "0x"&hex(GUICtrlRead($input1),2)&hex(GUICtrlRead($input2),2)&hex(GUICtrlRead($input3),2))
EndFunc

Func _slider2()
  GUICtrlSetBkColor($label2, "0x00"&hex(GUICtrlRead(@GUI_CTRLID),2)&"00")
  GUICtrlSetData($label2_hv,hex(GUICtrlRead(@GUI_CTRLID),2))
  GUICtrlSetData($hex,"0x"&hex(GUICtrlRead($input1),2)&hex(GUICtrlRead($input2),2)&hex(GUICtrlRead($input3),2))
  GUICtrlSetBkColor($label4, "0x"&hex(GUICtrlRead($input1),2)&hex(GUICtrlRead($input2),2)&hex(GUICtrlRead($input3),2))
EndFunc

Func _slider3()
  GUICtrlSetBkColor($label3, "0x0000"&hex(GUICtrlRead(@GUI_CTRLID),2))
  GUICtrlSetData($label3_hv,hex(GUICtrlRead(@GUI_CTRLID),2))
  GUICtrlSetData($hex,"0x"&hex(GUICtrlRead($input1),2)&hex(GUICtrlRead($input2),2)&hex(GUICtrlRead($input3),2))
  GUICtrlSetBkColor($label4, "0x"&hex(GUICtrlRead($input1),2)&hex(GUICtrlRead($input2),2)&hex(GUICtrlRead($input3),2))
EndFunc

Func CLOSEClicked()
      Exit
EndFunc
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...