Jump to content



Photo

ColorChooser UDF


  • Please log in to reply
10 replies to this topic

#1 Yashied

Yashied

    Happy in Moscow

  • MVPs
  • 2,512 posts

Posted 24 March 2010 - 09:59 PM

LAST VERSION - 1.1
07-Dec-10

This library provides a dialog box to select a color in three color models - RGB (Red, Green, Blue), HSL (Hue, Saturation, Lightness), and HSB (Hue, Saturation, Brightness). This is not a program, this is a function that you can use in your scripts. This function is similar to the _ChooseColor() from Misc.au3 library that is included in the AutoIt package. UDF is fully compatible with the ColorPicker.au3 (v1.5) and can be used as a custom function for a "Color Chooser" dialog box (see examples). Also there is a tool (pipette) to get the color from the screen. I recommend to first read description inside the library. Please play with this UDF and post any comments and suggestions. Enjoy.


Posted Image


ColorChooser UDF Library v1.1
(Previous downloads: 316)

Attached File  ColorChooser.au3   46.87K   759 downloads


Example1

AutoIt         
#Include <ColorChooser.au3> Opt('MustDeclareVars', 1) Global $hForm, $Msg, $Label, $Button, $Data, $Color = 0x50CA1B $hForm = GUICreate('MyGUI', 170, 200) $Label = GUICtrlCreateLabel('', 15, 15, 140, 140, $SS_SUNKEN) GUICtrlSetBkColor(-1, $Color) $Button = GUICtrlCreateButton('Select color...', 35, 166, 100, 23) GUISetState() While 1     $Msg = GUIGetMsg()     Switch $Msg         Case $GUI_EVENT_CLOSE             ExitLoop         Case $Button             $Data = _ColorChooserDialog($Color, $hForm)             If $Data > -1 Then                 GUICtrlSetBkColor($Label, $Data)                 $Color = $Data             EndIf     EndSwitch WEnd


Example2 (required ColorPicker.au3)

AutoIt         
#Include <ColorChooser.au3> #Include <ColorPicker.au3> Opt('MustDeclareVars', 1) Global $hForm, $Msg, $Label, $Picker $hForm = GUICreate('MyGUI', 170, 200) $Label = GUICtrlCreateLabel('', 15, 15, 140, 140, $SS_SUNKEN) GUICtrlSetBkColor(-1, 0x50CA1B) $Picker = _GUIColorPicker_Create('', 55, 166, 60, 23, 0x50CA1B, BitOR($CP_FLAG_CHOOSERBUTTON, $CP_FLAG_MAGNIFICATION, $CP_FLAG_ARROWSTYLE), 0, -1, -1, 0, 'Simple Text', 'Custom...', '_ColorChooserDialog') GUISetState() While 1     $Msg = GUIGetMsg()     Switch $Msg         Case $GUI_EVENT_CLOSE             ExitLoop         Case $Picker             GUICtrlSetBkColor($Label, _GUIColorPicker_GetColor($Picker))     EndSwitch WEnd

Edited by Yashied, 07 December 2010 - 08:31 AM.

  • Belini likes this





#2 Yashied

Yashied

    Happy in Moscow

  • MVPs
  • 2,512 posts

Posted 29 March 2010 - 06:42 AM

The library has been updated.

#3 Shafayat

Shafayat

    Polymath

  • Active Members
  • PipPipPipPip
  • 245 posts

Posted 29 March 2010 - 07:42 AM

This is quite nice. And useful.

Thanks
[Not using this account any more. Using "iShafayet" instead]

#4 Yashied

Yashied

    Happy in Moscow

  • MVPs
  • 2,512 posts

Posted 20 April 2010 - 06:28 AM

The library has been updated.

v1.1

Changes

Spoiler


#5 Beege

Beege

    Universalist

  • MVPs
  • 843 posts

Posted 04 June 2010 - 02:42 AM

Yashid, I get the following errors when running example 1:

F:\AutoIt\Other People Projects and Examples\Yasheid\Color Choser UDF\ColorChooser.au3(1295,47) : ERROR: CP_WM_COMMAND(): undefined function.         CP_WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ F:\AutoIt\Other People Projects and Examples\Yasheid\Color Choser UDF\ColorChooser.au3(1469,59) : ERROR: CP_WM_SETCURSOR(): undefined function.         $Result = CP_WM_SETCURSOR($hWnd, $iMsg, $wParam, $lParam)


#6 Yashied

Yashied

    Happy in Moscow

  • MVPs
  • 2,512 posts

Posted 04 June 2010 - 06:09 AM

Yashid, I get the following errors when running example 1...

With this code you also get an error, but the code is absolutely correct. Do not pay any attention to it.

If (IsDeclared('A')) And ($A = 1) Then     MyFunc() EndIf

:mellow:

#7 Yashied

Yashied

    Happy in Moscow

  • MVPs
  • 2,512 posts

Posted 12 October 2010 - 12:48 AM

Small update.

;)

#8 tip

tip

    Adventurer

  • Active Members
  • PipPip
  • 103 posts

Posted 04 November 2010 - 11:30 AM

This requires really hard work. Thanks Yashied. I appreciate it...


Regards
Tip

MsgBox_Tipped: Eye candy msgboxes/inputboxes/loginboxes. | CreateBlankBox: Semi-transparent layers with borders and rounded corners.


#9 Yashied

Yashied

    Happy in Moscow

  • MVPs
  • 2,512 posts

Posted 07 December 2010 - 08:37 AM

The library has been updated. Now Au3Check shows no errors.

:graduated:

#10 happytc

happytc

    Adventurer

  • Active Members
  • PipPip
  • 119 posts

Posted 25 May 2011 - 05:20 PM

when R = 250, G = 250, B = 250, return value of ColorChooser function is H = 160, S = 0, L = 240

why here H = 160, instead of H = 0 ?

#11 PAEz

PAEz

    Seeker

  • Active Members
  • 19 posts

Posted 23 August 2011 - 09:20 AM

when R = 250, G = 250, B = 250, return value of ColorChooser function is H = 160, S = 0, L = 240

why here H = 160, instead of H = 0 ?


When Saturation is 0 it really doesnt matter what the Hue is because its still going to be grey/black/white and its very common in this instance for the hue to be set to the center of the colour wheel which is 160 in this case.

EDIT: Freakn great UDF....the color picker tool is just gravy!

Edited by PAEz, 23 August 2011 - 09:27 AM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users