Paulie Posted August 21, 2006 Share Posted August 21, 2006 (edited) With this tool, you move the sliders back and forth and it blends the colors and gives you the both Hex and Decimal valuesbased off this websitehttp://www.mathsisfun.com/hexadecimal-decimal-colors.htmlexpandcollapse popup#include <GuiConstants.au3> ; == GUI generated with Koda == Thank GOD for Koda!! $Decimal = GUICreate("Decimal and Hexadecimal Colors", 592, 299, 414, 191, -1, $WS_EX_TOOLWINDOW) GUISetBkColor(0xD4D0C8) $RedSlider = GUICtrlCreateSlider(75, 35, 255, 35, BitOR($TBS_BOTH,$TBS_NOTICKS), $WS_EX_CLIENTEDGE) $GreenSlider = GUICtrlCreateSlider(75, 90, 255, 35, BitOR($TBS_BOTH,$TBS_NOTICKS), $WS_EX_CLIENTEDGE) $BlueSlider = GUICtrlCreateSlider(75, 145, 255, 35, BitOR($TBS_BOTH,$TBS_NOTICKS), $WS_EX_CLIENTEDGE) GUICtrlSetLimit($RedSlider,255, 0) GUICtrlSetLimit($GreenSlider,255, 0) GUICtrlSetLimit($BlueSlider,255, 0) GUICtrlCreateLabel("Red:", 10, 35, 40, 22) GUICtrlSetFont(-1, 10, 800, 0, "Arial Black") GUICtrlSetColor(-1, 0xFF0000) GUICtrlSetBkColor(-1, 0xD4D0C8) GUICtrlCreateLabel("Green:", 10, 90, 58, 22) GUICtrlSetFont(-1, 10, 800, 0, "Arial Black") GUICtrlSetColor(-1, 0x008000) GUICtrlSetBkColor(-1, 0xD4D0C8) GUICtrlCreateLabel("Blue:", 10, 145, 45, 22) GUICtrlSetFont(-1, 10, 800, 0, "Arial Black") GUICtrlSetColor(-1, 0x0000FF) GUICtrlSetBkColor(-1, 0xD4D0C8) $Display = GUICtrlCreateLabel("", 370, 23, 200, 230, BitOR($SS_SUNKEN,$WS_BORDER), $WS_EX_CLIENTEDGE) GUICtrlSetBkColor(-1, 0x000000) $HexInput = GUICtrlCreateInput("000000", 215, 195, 135, 24, $ES_CENTER, $WS_EX_CLIENTEDGE) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0x000080) $DecInput = GUICtrlCreateInput("000000", 215, 235, 135, 24, BitOR($ES_CENTER,$ES_NUMBER), $WS_EX_CLIENTEDGE) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0x000080) $RedCount = GUICtrlCreateLabel("Red: 0 = 00", 15, 195, 130, 20) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0xFF0000) GUICtrlSetBkColor(-1, 0xD4D0C8) $GreenCount = GUICtrlCreateLabel("Green: 0 = 00", 15, 225, 140, 20) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0x008000) GUICtrlSetBkColor(-1, 0xD4D0C8) $BlueCount = GUICtrlCreateLabel("Blue: 0 = 00", 15, 255, 130, 20) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0x0000FF) GUICtrlSetBkColor(-1, 0xD4D0C8) GUICtrlCreateLabel("HEX:", 155, 195, 50, 27) GUICtrlSetFont(-1, 12, 800, 0, "Arial Black") GUICtrlSetBkColor(-1, 0xD4D0C8) GUICtrlCreateLabel("DEC:", 155, 235, 49, 27) GUICtrlSetFont(-1, 12, 800, 0, "Arial Black") GUICtrlSetBkColor(-1, 0xD4D0C8) GUISetState(@SW_SHOW) While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect $CurrentRed = GUICtrlRead($RedSlider) GuiCtrlSetData($RedCount, "Red: "&$CurrentRed&" = "&StringTrimLeft(Hex($CurrentRed),6)) $CurrentGreen = GUICtrlRead($GreenSlider) GuiCtrlSetData($GreenCount, "Green: "&$CurrentGreen&" = "&StringTrimLeft(Hex($CurrentGreen),6)) $CurrentBlue = GUICtrlRead($BlueSlider) GuiCtrlSetData($BlueCount, "Blue: "&$CurrentBlue&" = "&StringTrimLeft(Hex($CurrentBlue),6)) $OutHex = StringTrimLeft(Hex($CurrentRed),6)&StringTrimLeft(Hex($CurrentGreen),6)&StringTrimLeft(Hex($CurrentBlue),6) $OutDec = Dec($OutHex) GuiCtrlSetData($HexInput, $OutHex) GuiCtrlSetData($DecInput, $OutDec) GUICtrlSetBkColor($Display, "0x"&$OutHex) WEnd ExitOne problem is that I want the inputs to be able to be edited, so you can enter a hex or dec value ant it will display the color, is this possible since they are constantly being edited? or will i need more inputs? Edited August 21, 2006 by Paulie Link to comment Share on other sites More sharing options...
Zedna Posted August 21, 2006 Share Posted August 21, 2006 (edited) One problem is that I want the inputs to be able to be edited, so you can enter a hex or dec value ant it will display the color, is this possible since they are constantly being edited? or will i need more inputs?You can use GUIRegisterMsg() and react only on change value of sliders/edit boxes instead of your concept when you constantly update edit inputs from slider values.Then will be possible also manually edit values in edit boxes.Try to search on forum for examples about GUIRegisterMsg() ... Edited August 21, 2006 by Zedna Resources UDF Â ResourcesEx UDF Â AutoIt Forum Search Link to comment Share on other sites More sharing options...
GaryFrost Posted August 21, 2006 Share Posted August 21, 2006 Why not just use _ChooseColor? It's in the UDFs, Misc SciTE for AutoItDirections for Submitting Standard UDFs  Don't argue with an idiot; people watching may not be able to tell the difference.  Link to comment Share on other sites More sharing options...
Paulie Posted August 21, 2006 Author Share Posted August 21, 2006 Why not just use _ChooseColor?It's in the UDFs, MiscCause this gives you a preview of what color your choosing Link to comment Share on other sites More sharing options...
GaryFrost Posted August 21, 2006 Share Posted August 21, 2006 Cause this gives you a preview of what color your choosing So does the _ChooseColor, it uses the system color dialog. SciTE for AutoItDirections for Submitting Standard UDFs  Don't argue with an idiot; people watching may not be able to tell the difference.  Link to comment Share on other sites More sharing options...
Paulie Posted August 21, 2006 Author Share Posted August 21, 2006 (edited) You can use GUIRegisterMsg() and react only on change value of sliders/edit boxes instead of your concept when you constantly update edit inputs from slider values.Then will be possible also manually edit values in edit boxes.Try to search on forum for examples about GUIRegisterMsg() ...I found it in the helpfile, but it makes NO sense to me at allhow am i supposed to know which 'windows message code'what if I don't have 4 parameters to make into a function?i'm confused And the example's not much help as it does more then the code i'm trying to make, my code could be It's example@gafrost-just wanted to copy that website more, it was more for learning then functionality Edited August 21, 2006 by Paulie Link to comment Share on other sites More sharing options...
Zedna Posted August 21, 2006 Share Posted August 21, 2006 I found it in the helpfile, but it makes NO sense to me at allhow am i supposed to know which 'windows message code'what if I don't have 4 parameters to make into a function?i'm confused That's why I said: search in forum for examples there are lots of nice educational scripts.And also www.msdn.com will help you. Resources UDF Â ResourcesEx UDF Â AutoIt Forum Search Link to comment Share on other sites More sharing options...
GaryFrost Posted August 21, 2006 Share Posted August 21, 2006 somthing for you to play around with expandcollapse popup#include <GuiConstants.au3> Global Const $DebugIt = 1 Global Const $WM_COMMAND = 0x0111 Global Const $EN_CHANGE = 0x300 ; == GUI generated with Koda == Thank GOD for Koda!! $Decimal = GUICreate("Decimal and Hexadecimal Colors", 592, 299, 414, 191, -1, $WS_EX_TOOLWINDOW) GUISetBkColor(0xD4D0C8) $RedSlider = GUICtrlCreateSlider(75, 35, 255, 35, BitOR($TBS_BOTH, $TBS_NOTICKS), $WS_EX_CLIENTEDGE) $GreenSlider = GUICtrlCreateSlider(75, 90, 255, 35, BitOR($TBS_BOTH, $TBS_NOTICKS), $WS_EX_CLIENTEDGE) $BlueSlider = GUICtrlCreateSlider(75, 145, 255, 35, BitOR($TBS_BOTH, $TBS_NOTICKS), $WS_EX_CLIENTEDGE) GUICtrlSetLimit($RedSlider, 255, 0) GUICtrlSetLimit($GreenSlider, 255, 0) GUICtrlSetLimit($BlueSlider, 255, 0) GUICtrlCreateLabel("Red:", 10, 35, 40, 22) GUICtrlSetFont(-1, 10, 800, 0, "Arial Black") GUICtrlSetColor(-1, 0xFF0000) GUICtrlSetBkColor(-1, 0xD4D0C8) GUICtrlCreateLabel("Green:", 10, 90, 58, 22) GUICtrlSetFont(-1, 10, 800, 0, "Arial Black") GUICtrlSetColor(-1, 0x008000) GUICtrlSetBkColor(-1, 0xD4D0C8) GUICtrlCreateLabel("Blue:", 10, 145, 45, 22) GUICtrlSetFont(-1, 10, 800, 0, "Arial Black") GUICtrlSetColor(-1, 0x0000FF) GUICtrlSetBkColor(-1, 0xD4D0C8) $Display = GUICtrlCreateLabel("", 370, 23, 200, 230, BitOR($SS_SUNKEN, $WS_BORDER), $WS_EX_CLIENTEDGE) GUICtrlSetBkColor(-1, 0x000000) $HexInput = GUICtrlCreateInput("000000", 215, 195, 135, 24, $ES_CENTER, $WS_EX_CLIENTEDGE) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0x000080) $DecInput = GUICtrlCreateInput("000000", 215, 235, 135, 24, BitOR($ES_CENTER, $ES_NUMBER), $WS_EX_CLIENTEDGE) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0x000080) $RedCount = GUICtrlCreateLabel("Red: 0 = 00", 15, 195, 130, 20) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0xFF0000) GUICtrlSetBkColor(-1, 0xD4D0C8) $GreenCount = GUICtrlCreateLabel("Green: 0 = 00", 15, 225, 140, 20) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0x008000) GUICtrlSetBkColor(-1, 0xD4D0C8) $BlueCount = GUICtrlCreateLabel("Blue: 0 = 00", 15, 255, 130, 20) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0x0000FF) GUICtrlSetBkColor(-1, 0xD4D0C8) GUICtrlCreateLabel("HEX:", 155, 195, 50, 27) GUICtrlSetFont(-1, 12, 800, 0, "Arial Black") GUICtrlSetBkColor(-1, 0xD4D0C8) GUICtrlCreateLabel("DEC:", 155, 235, 49, 27) GUICtrlSetFont(-1, 12, 800, 0, "Arial Black") GUICtrlSetBkColor(-1, 0xD4D0C8) GUISetState(@SW_SHOW) GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND") $CurrentRed = GUICtrlRead($RedSlider) $CurrentGreen = GUICtrlRead($GreenSlider) $CurrentBlue = GUICtrlRead($BlueSlider) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case Else If $CurrentRed <> GUICtrlRead($RedSlider) Or _ $CurrentGreen <> GUICtrlRead($GreenSlider) Or _ $CurrentBlue <> GUICtrlRead($BlueSlider) Then $CurrentRed = GUICtrlRead($RedSlider) GUICtrlSetData($RedCount, "Red: " & $CurrentRed & " = " & StringTrimLeft(Hex($CurrentRed), 6)) $CurrentGreen = GUICtrlRead($GreenSlider) GUICtrlSetData($GreenCount, "Green: " & $CurrentGreen & " = " & StringTrimLeft(Hex($CurrentGreen), 6)) $CurrentBlue = GUICtrlRead($BlueSlider) GUICtrlSetData($BlueCount, "Blue: " & $CurrentBlue & " = " & StringTrimLeft(Hex($CurrentBlue), 6)) $OutHex = StringTrimLeft(Hex($CurrentRed), 6) & StringTrimLeft(Hex($CurrentGreen), 6) & StringTrimLeft(Hex($CurrentBlue), 6) $OutDec = Dec($OutHex) GUICtrlSetData($HexInput, $OutHex) GUICtrlSetData($DecInput, $OutDec) GUICtrlSetBkColor($Display, "0x" & $OutHex) EndIf EndSelect WEnd Exit Func _Hex_Changed() ;---------------------------------------------------------------------------------------------- If $DebugIt Then _DebugPrint("_Hex_Changed:" & GUICtrlRead($HexInput)) ;---------------------------------------------------------------------------------------------- Local $Hex = GUICtrlRead($HexInput) If StringLen($Hex) = 6 Then If GUICtrlRead($RedSlider) <> Dec(StringMid($Hex, 1, 2)) Then GUICtrlSetData($RedSlider, Dec(StringMid($Hex, 1, 2))) EndIf If GUICtrlRead($GreenSlider) <> Dec(StringMid($Hex, 3, 2)) Then GUICtrlSetData($GreenSlider, Dec(StringMid($Hex, 3, 2))) EndIf If GUICtrlRead($BlueSlider) <> Dec(StringMid($Hex, 5, 2)) Then GUICtrlSetData($BlueSlider, Dec(StringMid($Hex, 5, 2))) EndIf EndIf EndFunc ;==>_Hex_Changed Func _Dec_Changed() ;---------------------------------------------------------------------------------------------- If $DebugIt Then _DebugPrint("_Dec_Changed:" & GUICtrlRead($DecInput)) ;---------------------------------------------------------------------------------------------- Local $Hex = Hex(GUICtrlRead($DecInput), 6) If StringLen($Hex) = 6 Then If GUICtrlRead($RedSlider) <> Dec(StringMid($Hex, 1, 2)) Then GUICtrlSetData($RedSlider, Dec(StringMid($Hex, 1, 2))) EndIf If GUICtrlRead($GreenSlider) <> Dec(StringMid($Hex, 3, 2)) Then GUICtrlSetData($GreenSlider, Dec(StringMid($Hex, 3, 2))) EndIf If GUICtrlRead($BlueSlider) <> Dec(StringMid($Hex, 5, 2)) Then GUICtrlSetData($BlueSlider, Dec(StringMid($Hex, 5, 2))) EndIf EndIf EndFunc ;==>_Dec_Changed Func MY_WM_COMMAND($hWnd, $msg, $wParam, $lParam) Local $nNotifyCode = _HiWord($wParam) Local $nID = _LoWord($wParam) Local $hCtrl = $lParam Switch $nID Case $HexInput Switch $nNotifyCode Case $EN_CHANGE _Hex_Changed() EndSwitch Case $DecInput Switch $nNotifyCode Case $EN_CHANGE _Dec_Changed() EndSwitch EndSwitch ; Proceed the default Autoit3 internal message commands. ; You also can complete let the line out. ; !!! But only 'Return' (without any value) will not proceed ; the default Autoit3-message in the future !!! Return $GUI_RUNDEFMSG EndFunc ;==>MY_WM_COMMAND Func _DebugPrint($s_text) $s_text = StringReplace($s_text, @LF, @LF & "-->") ConsoleWrite("!===========================================================" & @LF & _ "+===========================================================" & @LF & _ "-->" & $s_text & @LF & _ "+===========================================================" & @LF) EndFunc ;==>_DebugPrint Func _HiWord($x) Return BitShift($x, 16) EndFunc ;==>_HiWord Func _LoWord($x) Return BitAND($x, 0xFFFF) EndFunc ;==>_LoWord SciTE for AutoItDirections for Submitting Standard UDFs  Don't argue with an idiot; people watching may not be able to tell the difference.  Link to comment Share on other sites More sharing options...
Paulie Posted August 22, 2006 Author Share Posted August 22, 2006 somthing for you to play around with ;(Snip)That is amazing gafrost Thanks very much, i like that!! Link to comment Share on other sites More sharing options...
Jikoo Posted November 5, 2008 Share Posted November 5, 2008 (edited) Thank you Paulie, Zedna and GaryFrost for this excellent script. I modified this script and put it in my tool : GCS Search Edited April 1, 2009 by Jikoo My projects : GCS Search 1.07 (GUI Control Styles Search)* Multilingual tool to help about the old scripts, with a dynamic menu.* Easy way to find missing Include files in old scripts downloaded from forums !* Famous Monoceres script added and improved (visual, drag and drop, automatic)* There is an interactive color converter with palettes too, for fun !The best way to start Autoit3 development (for newbies). 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