GreenCan Posted March 6, 2009 Share Posted March 6, 2009 (edited) For the ExcelCOM_UDF users amongst you. This color pickup tool will allow you to select a color from the standard Excel color palette (same as the Excel color pane). I think that this could be useful if you plan to develop Excel outputs in AutoIt. Greencan PS. I didn't find a way to implement the color option 2 of the ExcelCOM_UDF where $iColorIndex > 254 and $hColor Hex value of color is used. The colors are always different between Excel and Windows. I was tired of trying to understand the differences so this udf only functions with the interior color index With a little bit of modification, this udf could be used for other means. Edit: March 6, 21:50 Corrected a bug and color panel now displays the default color. expandcollapse popup;=============================================================================== ; Function: _ColorPicker ; Version: AutoIt Version: 3.3.0.0 ; Description: Color Picker Tool for Excel Current Workbook Pallet ; Returns the selected color ; Syntax: _ColorPicker($_CPleft, $_CPTop, $_DefaultColor = "", $_Title = "Color Picker") ; Parameter(s): $_CPleft - Left position of the Color Picker Window ; $_CPTop - Top position of the Color Picker Window ; $_DefaultColor - Array (element ; $_Title - Optional title of the Color Picker Window ; $_Font - Logical, if True, then it is a font color, important for the default return which should be black ; Requirement(s): None ; Return Value(s): On Success - Returns an Array Array with the following format: ; [0] AutoIt Hex color ; [1] Excel Color number ; When Default/Transparent button is clicked ; [0] AutoIt color 0xFFFFFF ; [1] Excel Color 0 (black/transparent) ; On Failure, more exactly on Escape or Enter - Returns: ; [0] -1 or the default Hex color ; [1] -1 or the default Excel Color number ; @error=1 - Specified object does not exist ; Author(s): A. Greencan - March 2009 ; Note(s): Excel Color information can be found on ; http://www.mvps.org/dmcritchie/excel/colors.htm ; ; Color table $ExcelColors ; The table is the standard palet of Excel 2003 ; The color table can be expanded to contain all color elements, from 0 (transparent) to color 56 ; The window size will grow dynaically ; Each color element contains: ; [0] Hex number of the Windows color ; [1] Number of the Excel color ; [2] Name of the color ; [3] Return value of the button ; ;=============================================================================== #include-once #include <WindowsConstants.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> Func _ColorPicker($_CPleft = -1, $_CPTop = -1, $_DefaultColor = "", $_Title = "Color picker", $_Font = False) Local $_CP_GUI, $_TransparentBtn, $_HorCounter, $_VertCounter, $_a, $_msg, $_result, $_DummytBtn ; Color table Local $ExcelColors[40][4] = [ _ [0x000000,1,"Black",""], _ [0x993300,53,"Brown",""], _ [0x333300,52,"Olive Green",""], _ [0x003300,51,"Dark Green",""], _ [0x003366,49,"Dark Teal",""], _ [0x000080,11,"Dark Blue",""], _ [0x333399,55,"Indigo",""], _ [0x333333,56,"Gray-80%",""], _ [0x800000,9,"Dark Red",""], _ [0xFF6600,46,"Orange",""], _ [0x808000,12,"Dark Yellow",""], _ [0x008000,10,"Green",""], _ [0x008080,14,"Teal",""], _ [0x0000FF,5,"Blue",""], _ [0x666699,47,"Blue-Gray",""], _ [0x808080,16,"Gray-50%",""], _ [0xFF0000,3,"Red",""], _ [0xFF9900,45,"Light Orange",""], _ [0x99CC00,43,"Lime",""], _ [0x339966,50,"Sea Green",""], _ [0x33CCCC,42,"Aqua",""], _ [0x3366FF,41,"Light Blue",""], _ [0x800080,13,"Violet",""], _ [0x969696,48,"Gray-40%",""], _ [0xFF00FF,7,"Pink",""], _ [0xFFCC00,44,"Gold",""], _ [0xFFFF00,6,"Yellow",""], _ [0x00FF00,4,"Bright Green",""], _ [0x00FFFF,8,"Turquoise",""], _ [0x00CCFF,33,"Sky Blue",""], _ [0x993366,54,"Plum",""], _ [0xC0C0C0,15,"Gray-25%",""], _ [0xFF99CC,38,"Rose",""], _ [0xFFCC99,40,"Tan",""], _ [0xFFFF99,36,"Light Yellow",""], _ [0xCCFFCC,35,"Light Green",""], _ [0xCCFFFF,34,"Light Turquoise",""], _ [0x99CCFF,37,"Pale Blue",""], _ [0xCC99FF,39,"Lavender",""], _ [0xFFFFFF,2,"White",""]] If $_DefaultColor <> "" Then ConsoleWrite("default : " & "0x" & Hex($_DefaultColor[0][0],6) & " - Excel: " & $_DefaultColor[0][1] & @CR) If $_DefaultColor[0][1] = 0 Then $_result = -1 ; set for Default/Transparent button Else $_result = _ArraySearch($ExcelColors, $_DefaultColor[0][0], -1, -1, -1, -1, 0 ) EndIf EndIf ConsoleWrite("result: " & $_result & @CR) If $_CPleft = -1 Then $_CPleft = ((@DesktopWidth - 215)/2) If $_CPTop = -1 Then $_CPTop = ((@DesktopHeight - 165)/2) $_CP_GUI = GUICreate($_Title, 215, 35 + (26 * round((0.4+(UBound($ExcelColors)/8)),0)),$_CPleft,$_CPTop,-1, $WS_EX_TOOLWINDOW) ; dummy button, need to create this to catch the enter which means no change $_DummytBtn = GUICtrlCreateButton("", 0, 0, 0, 0, $BS_DEFPUSHBUTTON) If $_result = -1 Then GUICtrlCreatelabel("", 5 ,5 ,205, 26 ,$SS_BLACKRECT ) $_TransparentBtn = GUICtrlCreateButton("Default/Transparent", 7, 7, 201, 22) Else $_TransparentBtn = GUICtrlCreateButton("Default/Transparent", 5, 5, 205, 26) EndIf GuiCtrlSetBkColor(-1, 0xFFFFFF ) GUICtrlSetTip(-1, "Default") $_HorCounter = 0 $_VertCounter = 0 For $_a = 0 to UBound($ExcelColors) - 1 If $_HorCounter = 8 Then $_HorCounter = 1 $_VertCounter = $_VertCounter + 1 Else $_HorCounter = $_HorCounter + 1 EndIf If $_a = $_result Then ; default color GUICtrlCreatelabel("", 5 - 26 + ($_HorCounter * 26 ),5 + 26 + ($_VertCounter *26),24,24 ,$SS_BLACKRECT ) $ExcelColors[$_a][3] = GUICtrlCreateButton("", 7 - 26 + ($_HorCounter * 26 ),7 + 26 + ($_VertCounter *26),20,20 ) Else $ExcelColors[$_a][3] = GUICtrlCreateButton("", 5 - 26 + ($_HorCounter * 26 ),5 + 26 + ($_VertCounter *26),24,24 ) EndIf GuiCtrlSetBkColor(-1, $ExcelColors[$_a][0]) GUICtrlSetTip(-1, $ExcelColors[$_a][2]) Next GUISetState() $_msg = 0 While $_msg <> $GUI_EVENT_CLOSE $_msg = GUIGetMsg() Select Case $_msg = $_TransparentBtn ; Transparent / default button will return 0 GUIDelete ( $_CP_GUI ) If $_Font = True Then local $res[1][2] = [[0x000000,0]] ; foreground should be black Else local $res[1][2] = [[0xFFFFFF,0]] ; background should be white EndIf Return($res) Case $_msg = 6 Or $_msg = $GUI_EVENT_CLOSE; enter or Escape - no change, will return -1 or the default color GUIDelete ( $_CP_GUI ) If $_DefaultColor <> "" Then ; we will keep the default color if known, otherwise, return -1 ;local $res[1][2] = [[$ExcelColors[$_result][0],$ExcelColors[$_result][1]]] Return($_DefaultColor) Else local $res[1][2] = [[-1,-1]] Return($res) EndIf Case Else ; returns selected color numbers For $_a = 0 to UBound($ExcelColors) - 1 If $_msg = $ExcelColors[$_a][3] Then GUIDelete ( $_CP_GUI ) local $res[1][2] = [[$ExcelColors[$_a][0],$ExcelColors[$_a][1]]] Return($res) EndIf Next EndSelect WEnd EndFunc ;==>_ColorPickeroÝ÷ Ø*%¢ºbrG«{¦¦W¢±1qéZ»v®¶sb672ÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÐ ¢WFôBfW'6öã¢2ã2ãã¢WF÷#¢âw&VVä6à Ö&6# ¢67&BgVæ7Föã W×ÆR6öÆ÷"6·WFööÂW6VÂ6öÆ÷'2W6ærçFW&÷"ä6öÆ÷$æFW ¥&WV&W3¢6æ6ÇVFRfÇCµô6öÆ÷%6¶W"æS2fwC° ¢66RÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒТ6æ6ÇVFRfÇCµ7FF46öç7FçG2æS2fwC°¢6æ6ÇVFRfÇC´'&æS2fwC°¢6æ6ÇVFRfÇC´W6VÄ4ôÕõTDbæS2fwC²¢6æ6ÇVFRfÇCµô6öÆ÷%6¶W"æS2fwC°£²â&W&RFRW×ÆP ¤Æö6Âb33c¶ôW6VÂÒôW6VÄ&öö´æWr²÷VâæWrW6VÂ&öö°¥ôW6VÅw&FT6VÆÂb33c¶ôW6VÂÂgV÷C´W6VÂföçBæB&6¶w&÷VæB6öÆ÷&ærW×ÆRgV÷C²ÂgV÷C´gV÷C²²w&FRDDÄRFòFRf'7B6VÆÂöbFRf'7B6VW@¥ôW6VÄföçE6WBb33c¶ôW6VÂÂgV÷C´¤gV÷C²ÂÂÂÂgV÷C´''W667&B7FBgV÷C²²6WBföç@¥ôW6VÄföçE6WE6¦Rb33c¶ôW6VÂÂgV÷C´¤gV÷C²ÂÂÂÂ3²6WBFRföçB6¦P£µôW6VÄföçE6WE&÷W'FW2b33c¶ôW6VÂÂgV÷C´¤gV÷C²ÂÂÂÂG'VRÂfÇ6RÂfÇ6R²6WB&öÆ@¥ôW6VÄ6öÅvGF6WBb33c¶ôW6VÂÂgV÷C´¤gV÷C²ÂgV÷C¶WFöfBgV÷C²²6WBFR6öÇVÖâvGF¥ôW6VÅ6÷rb33c¶ôW6V²6÷rFR6VW@ £²6WBFR&6¶w&÷VæBæBföçBfÇVRf÷"F2FVÖð¤FÒb33c¶&u÷fÇVU³Õ³%ÒÒµ³dbÃUÕФFÒb33c¶fu÷fÇVU³Õ³%ÒÒµ³dddddbÃ%ÕÐ ¥ôW6VÄ6VÆÄ6öÆ÷%6WBb33c¶ôW6VÂÂgV÷C´¤gV÷C²ÂÂÂÂb33c¶&u÷fÇVU³Õ³Ò²6öÆ÷"FR&6¶w&÷Væ@¥ôW6VÄföçE6WD6öÆ÷"b33c¶ôW6VÂÂgV÷C´¤gV÷C²ÂÂÂÂb33c¶fu÷fÇVU³Õ³Ò²föçB6öÆ÷ £²"â6WBFRuTvF6öÆ÷"6ævW ¢b33c¶uTÒuT7&VFRgV÷C´6öÆ÷"6¶W"W×ÆRgV÷C²Ã3ÃSÂÓÂÓ¢b33cµôW6VÄ6VÆÄ6öÆ÷"ÒuT7G&Ä7&VFTÆ&VÂgV÷C´W6VÂ6VÆÂ6öÆ÷"gV÷C²ÂCÂSÂcÂSÂb33cµ55ô4TåDU"¤wV7G&Å6WD&´6öÆ÷"b33cµôW6VÄ6VÆÄ6öÆ÷"Âb33c¶&u÷fÇVU³Õ³Ò¤uT7G&Å6WD6öÆ÷"b33cµôW6VÄ6VÆÄ6öÆ÷"Âb33c¶fu÷fÇVU³Õ³Ò¤uT7G&Å6WDföçBÓÂÂc ¢b33cµô$t6öÆ÷$'FâÒuT7G&Ä7&VFT'WGFöâgV÷C´6ævR&6¶w&÷VæB6öÆ÷"gV÷C²ÂÂSÂSÂ#"¢b33cµôdt6öÆ÷$'FâÒuT7G&Ä7&VFT'WGFöâgV÷C´6ævRföçB6öÆ÷"gV÷C²ÂÂÂSÂ#"²Âb33c´%5ôDTeU4%UEDôâ ¤uT6WE7FFR ¢b33c¶×6rÒ¥vÆRb33c¶×6rfÇC²fwC²b33c´uTôUdTåEô4Äõ4P b33c¶×6rÒuTvWD×6r 6VÆV7@ 66Rb33c¶×6rÒb33cµô$t6öÆ÷$'Fà b33c¶&u÷fÇVRÒô6öÆ÷%6¶W"ÓÂÓÂb33c¶&u÷fÇVRÂgV÷C´&6¶w&÷VæB6öÆ÷"gV÷C² bb33c¶&u÷fÇVU³Õ³ÒfÇC²fwC²ÓFVà 6öç6öÆUw&FRgV÷C´&6¶w&÷VæBWFöC¢gV÷C²fײgV÷C³gV÷C²fײWb33c¶&u÷fÇVU³Õ³ÒÃbfײgV÷C²ÒW6VâgV÷C²fײb33c¶&u÷fÇVU³Õ³Òfײ5" wV7G&Å6WD&´6öÆ÷"b33cµôW6VÄ6VÆÄ6öÆ÷"Âb33c¶&u÷fÇVU³Õ³Ò ôW6VÄ6VÆÄ6öÆ÷%6WBb33c¶ôW6VÂÂgV÷C´¤gV÷C²ÂÂÂÂb33c¶&u÷fÇVU³Õ³Ò²6öÆ÷"FR&6¶w&÷Væ@ VæD` 66Rb33c¶×6rÒb33cµôdt6öÆ÷$'Fà b33c¶fu÷fÇVRÒô6öÆ÷%6¶W"ÓÂÓÂb33c¶fu÷fÇVRÂgV÷C´föçB6öÆ÷"gV÷C²ÂG'VR bb33c¶fu÷fÇVU³Õ³ÒfÇC²fwC²ÓFVà 6öç6öÆUw&FRgV÷C´föçBWFöC¢gV÷C²fײgV÷C³gV÷C²fײWb33c¶fu÷fÇVU³Õ³ÒÃbfײgV÷C²ÒW6VâgV÷C²fײb33c¶fu÷fÇVU³Õ³Òfײ5" uT7G&Å6WD6öÆ÷"b33cµôW6VÄ6VÆÄ6öÆ÷"Âb33c¶fu÷fÇVU³Õ³Ò ôW6VÄföçE6WD6öÆ÷"b33c¶ôW6VÂÂgV÷C´¤gV÷C²ÂÂÂÂb33c¶fu÷fÇVU³Õ³Ò²föçB6öÆ÷ VæD` 66Rb33c¶×6rÒÓ2²W66R¶W&W76VB6òV@ WDÆö÷ VæE6VÆV7@¥tVæ@ ¤×6t&÷ÂgV÷C²gV÷C²ÂgV÷CµFR6VÆV7FVB6öÆ÷'2&S¢gV÷C²fײ5"fײ5"fײgV÷C´föçC¢gV÷C²fײ5"fײgV÷C´WFöC¢gV÷C²fײgV÷C³gV÷C²fײWb33c¶fu÷fÇVU³Õ³ÒÃbfײgV÷C²ÒW6VâgV÷C²fײb33c¶fu÷fÇVU³Õ³Òfײ5"fײ5"fײgV÷C´&6¶w&÷VæC¢gV÷C²fײ5"fײgV÷C´WFöC¢gV÷C²fײgV÷C³gV÷C²fײWb33c¶&u÷fÇVU³Õ³ÒÃbfײgV÷C²ÒW6VâgV÷C²fײb33c¶&u÷fÇVU³Õ³Òfײ5"fײ5"fײgV÷C´6Æ÷6ærF÷vâW6VÂgV÷C²£²6Æ÷6R÷W@¥ôW6VÄ&öö´6Æ÷6Rb33c¶ôW6V Edited March 6, 2009 by GreenCan Contributions CheckUpdate - SelfUpdating script ------- Self updating script Dynamic input validation ------------------- Use a Input masks can make your life easier and Validation can be as simple MsgBox with CountDown ------------------- MsgBox with visual countdown Display Multiline text cells in ListView ---- Example of pop-up or ToolTip for multiline text items in ListView Presentation Manager ---------------------- Program to display and refresh different Border-less GUI's on a Display (large screen TV) USB Drive Tools ------------------------------ Tool to help you with your USB drive management Input Period udf ------------------------------ GUI for a period input Excel ColorPicker ---------------------------- Color pickup tool will allow you to select a color from the standard Excel color palette Excel Chart UDF ----------------------------- Collaboration project with water GetDateInString ------------------------------ Find date/time in a string using a date format notation like DD Mon YYYY hh:mm TaskListAllDetailed --------------------------- List All Scheduled Tasks Computer Info --------------------------------- A collection of information for helpdesk Shared memory Demo ----------------------- Demo: Two applications communicate with each other through means of a memory share (using Nomad function, 32bit only) Universal Date Format Conversion -------- Universal date converter from your PC local date format to any format Disable Windows DetailsPane -------------- Disable Windows Explorer Details Pane Oracle SQL Report Generator ------------- Oracle Report generator using SQL SQLite Report Generator ------------------- SQLite Report generator using SQL SQLite ListView and BLOB demo ---------- Demo: shows how binary (image) objects can be recognized natively in a database BLOB field DSN-Less Database connection demo --- Demo: ActiveX Data Objects DSN-Less Database access Animated animals ----------------------------- Fun: Moving animated objects Perforated image in GUI --------------------- Fun: Perforate your image with image objects UEZ's Perforator major update ------------- Fun: Pro version of Perforator by UEZ Visual Crop Tool (GUI) ----------------------- Easy to use Visual Image Crop tool Visual Image effect (GUI) -------------------- Visually apply effects on an image Link to comment Share on other sites More sharing options...
ptrex Posted March 6, 2009 Share Posted March 6, 2009 @GreenCan Can be useful !! Thanks ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
GreenCan Posted March 6, 2009 Author Share Posted March 6, 2009 Thanks ptrex, I found a bug Corrected it and enhanced a bit The color panel now makes the default color visible. To make the button visible I had to create a label under it, I couldn't find a better method. I added a 5th parameter, the default return for the font was white but it needed to be black, so I had to pass 'foreground/background' to the function . I worked too hard on this thing, costed me 3 evenings... Excel is so weird with the color use, not very Windows standard if you ask me. I would have prefered to use the _ChooseColor function but that was way too easy... Neither possible to create something to make the full 3136 Excel colors selectable. Thanks Bill ! GreenCan Contributions CheckUpdate - SelfUpdating script ------- Self updating script Dynamic input validation ------------------- Use a Input masks can make your life easier and Validation can be as simple MsgBox with CountDown ------------------- MsgBox with visual countdown Display Multiline text cells in ListView ---- Example of pop-up or ToolTip for multiline text items in ListView Presentation Manager ---------------------- Program to display and refresh different Border-less GUI's on a Display (large screen TV) USB Drive Tools ------------------------------ Tool to help you with your USB drive management Input Period udf ------------------------------ GUI for a period input Excel ColorPicker ---------------------------- Color pickup tool will allow you to select a color from the standard Excel color palette Excel Chart UDF ----------------------------- Collaboration project with water GetDateInString ------------------------------ Find date/time in a string using a date format notation like DD Mon YYYY hh:mm TaskListAllDetailed --------------------------- List All Scheduled Tasks Computer Info --------------------------------- A collection of information for helpdesk Shared memory Demo ----------------------- Demo: Two applications communicate with each other through means of a memory share (using Nomad function, 32bit only) Universal Date Format Conversion -------- Universal date converter from your PC local date format to any format Disable Windows DetailsPane -------------- Disable Windows Explorer Details Pane Oracle SQL Report Generator ------------- Oracle Report generator using SQL SQLite Report Generator ------------------- SQLite Report generator using SQL SQLite ListView and BLOB demo ---------- Demo: shows how binary (image) objects can be recognized natively in a database BLOB field DSN-Less Database connection demo --- Demo: ActiveX Data Objects DSN-Less Database access Animated animals ----------------------------- Fun: Moving animated objects Perforated image in GUI --------------------- Fun: Perforate your image with image objects UEZ's Perforator major update ------------- Fun: Pro version of Perforator by UEZ Visual Crop Tool (GUI) ----------------------- Easy to use Visual Image Crop tool Visual Image effect (GUI) -------------------- Visually apply effects on an image Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now