HankHell Posted October 5, 2019 Share Posted October 5, 2019 (edited) Needed this for copying specific colors without the need for color lookup. Just figured it might be useful to someone. tracks your mouse and gives color feedback in realtime; in hex, dec, and rgb, as well as mouse coordinates F1 to toggle pause. up/down/left/right to move 1 pixel at a time. expandcollapse popup#include <GUIConstants.au3> #include <Color.au3> #include <WindowsConstants.au3> #include <Misc.au3> HotKeySet("{F1}", "Toggle") Global $Mpos_x Global $Mpos_y Global $ColorVar Global $iColor Global $Red, $Green, $Blue Global $ToggleState $GUI = GUICreate("Coords", 125, 195, 0, 0, $WS_POPUP) $bar = GUICtrlCreateLabel("", -5, -5, 135, 20) GUICtrlCreateInput("",-1,-1, 1, 1) GUICtrlSetBkColor($bar, 0x898989) GUICtrlSetState($bar, $GUI_DISABLE) $close = GUICtrlCreateLabel("", 110, -1, 15, 20) GUICtrlSetBkColor($close, 0xD9403B) GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST") $xylabel = GUICtrlCreateLabel("X=" & @CRLF & "Y=", 1, 20, 15, 30) $Label_x_value = GUICtrlCreateLabel("", 17, 20, 50, 11) $Label_y_value = GUICtrlCreateLabel("", 17, 35, 50, 11) GUICtrlCreateLabel("R,G,B", 65, 25, 35, 11) $RGB = GUICtrlCreateLabel("", 60, 40, 60, 11) $copyrgb = GUICtrlCreateButton("+", 97, 23, 25, 15) GUICtrlSetTip($copyrgb, "Copy RGB to clipboard") GUICtrlCreateLabel("Hex Color", 1, 55, 50, 11) $hextext = GUICtrlCreateLabel("", 1, 70, 55, 11) $copyhex = GUICtrlCreateButton("+", 55, 55, 15, 25) GUICtrlSetTip($copyhex, "Copy HEX to clipboard") GUICtrlCreateLabel("Dec Color", 1, 85, 55, 11) $dectext = GUICtrlCreateLabel("", 1, 100, 50, 11) $copydec = GUICtrlCreateButton("+", 55, 85, 15, 25) GUICtrlSetTip($copydec, "Copy DEC to clipboard") $buttoncolor = GUICtrlCreateButton("", 73, 55, 50, 57) $colorset1 = GUICtrlCreateButton("", 1, 115, 35, 35) $set1 = GUICtrlCreateButton("-", 1, 115, 15, 15) GUICtrlSetState($colorset1, $GUI_DISABLE) $colorset2 = GUICtrlCreateButton("", 43, 115, 35, 35) $set2 = GUICtrlCreateButton("-", 43, 115, 15, 15) GUICtrlSetState($colorset2, $GUI_DISABLE) $colorset3 = GUICtrlCreateButton("", 85, 115, 35, 35) $set3 = GUICtrlCreateButton("-", 85, 115, 15, 15) GUICtrlSetState($colorset3, $GUI_DISABLE) $colorset4 = GUICtrlCreateButton("", 1, 155, 35, 35) $set4 = GUICtrlCreateButton("-", 1, 155, 15, 15) GUICtrlSetState($colorset4, $GUI_DISABLE) $colorset5 = GUICtrlCreateButton("", 43, 155, 35, 35) $set5 = GUICtrlCreateButton("-", 43, 155, 15, 15) GUICtrlSetState($colorset5, $GUI_DISABLE) $colorset6 = GUICtrlCreateButton("", 85, 155, 35, 35) $set6 = GUICtrlCreateButton("-", 85, 155, 15, 15) GUICtrlSetState($colorset6, $GUI_DISABLE) GUISetState(@SW_SHOW) Toggle() While 1 Sleep(10) SwitchCheck() WEnd Func Toggle() $ToggleState = Not $ToggleState While $ToggleState Sleep(10) Get_Mouse_Pos() SwitchCheck() IfPressed() If Not $ToggleState Then Sleep(10) EndIf WEnd EndFunc Func SwitchCheck() $nMsg = GUIGetMsg() Switch $nMsg Case $close Exit Case $copyhex ClipPut($ColorVar) Case $copydec ClipPut($iColor) Case $copyrgb ClipPut($Red&","&$Green&","&$Blue) Case $set1 GUICtrlSetBkColor($colorset1, $ColorVar) Case $set2 GUICtrlSetBkColor($colorset2, $ColorVar) Case $set3 GUICtrlSetBkColor($colorset3, $ColorVar) Case $set4 GUICtrlSetBkColor($colorset4, $ColorVar) Case $set5 GUICtrlSetBkColor($colorset5, $ColorVar) Case $set6 GUICtrlSetBkColor($colorset6, $ColorVar) EndSwitch EndFunc Func Get_Mouse_Pos() GUISetState(@SW_SHOW) $Mpos = MouseGetPos() $Mpos_x = $Mpos[0] $Mpos_y = $Mpos[1] GUICtrlSetData($Label_x_value, $Mpos_x) GUICtrlSetData($Label_y_value, $Mpos_y) $iColor = PixelGetColor($Mpos[0], $Mpos[1]) $ColorVar = "0x" & Hex($iColor, 6) GUICtrlSetBkColor($buttoncolor, $ColorVar) GUICtrlSetData($hextext, $ColorVar) GUICtrlSetData($dectext, $iColor) $Red = _ColorGetRed($iColor) $Green = _ColorGetGreen($iColor) $Blue = _ColorGetBlue($iColor) GUICtrlSetData($RGB, $Red&","&$Green&","&$Blue) EndFunc Func IfPressed() If _IsPressed(26) Then Sleep(100) MouseMove(($Mpos_x + 0) , ($Mpos_y - 1), 0) EndIf If _IsPressed(28) Then Sleep(100) MouseMove(($Mpos_x + 0) , ($Mpos_y + 1), 0) EndIf If _IsPressed(25) Then Sleep(100) MouseMove(($Mpos_x - 1) , ($Mpos_y + 0), 0) EndIf If _IsPressed(27) Then Sleep(100) MouseMove(($Mpos_x + 1) , ($Mpos_y + 0), 0) EndIf EndFunc Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam) If $hWnd = $gui And $iMsg = $WM_NCHITTEST Then Return $HTCAPTION EndFunc Edited October 12, 2019 by HankHell cleaned up code a tiny bit ahmeddzcom, Jury and Skeletor 3 Link to comment Share on other sites More sharing options...
dmob Posted October 8, 2019 Share Posted October 8, 2019 Nice tool. Would be more useful if you could copy color selected to clipboard... HankHell 1 Link to comment Share on other sites More sharing options...
HankHell Posted October 12, 2019 Author Share Posted October 12, 2019 On 10/8/2019 at 11:13 AM, dmob said: Nice tool. Would be more useful if you could copy color selected to clipboard... you're absolutely right, I changed the code a bit in accordance, it also works much better with _ispressed Link to comment Share on other sites More sharing options...
Skeletor Posted October 23, 2019 Share Posted October 23, 2019 Awesome tool. Helps alot so I don't need to keep GIMP open everytime to check for colours. (colors) Kind RegardsSkeletor "Coffee: my defense against going postal." Microsoft Office Splash Screen | Basic Notepad Program (Beginner) | Transparent Splash Screen | Full Screen UI Link to comment Share on other sites More sharing options...
jchd Posted October 23, 2019 Share Posted October 23, 2019 I've been using Faststone Capture for 10+ years and its one of the thing I can't live witout. It's void of nastyware, light and full of goodies. All Faststone products are worth a look. Image Viewer and Photo Resizer are freeware and also part of my basic setup on any PC. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
Musashi Posted October 23, 2019 Share Posted October 23, 2019 1 hour ago, jchd said: I've been using Faststone Capture for 10+ years and its one of the thing I can't live without. May I ask, which version you are using? The last real freeware of FastStone Capture seems to be the version 5.3 (Feb. 2007). Current versions are shareware with a 30 days trial period. "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Link to comment Share on other sites More sharing options...
jchd Posted October 23, 2019 Share Posted October 23, 2019 I've registered (and paid for a lifetime) for Capture and when I checked it out today I updated to the latest 9.2. The two other mentionned utilities are freeware. BTW even the 5.3 version should please you, albeit not offering the latest additions. I never pretended that today's Capture was free: worth trying but not free. Musashi 1 This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
Musashi Posted October 23, 2019 Share Posted October 23, 2019 Thanks for your answer. 2 hours ago, jchd said: I never pretended that today's Capture was free: worth trying but not free. No, you didn't say that, of course ! My statement "The last real freeware of FastStone Capture seems to be the version 5.3" was therefore possibly misleading . I guess, I'll purchase the actual version. The developers also have to make a living from something, otherwise good software will finally disappear. "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." 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