ShareX.exe -ColorPicker
for those who don't know !
ShareX is a free and open source program - Screen capture, file sharing and productivity tool
ColorPicker It is a separate tool of his where you can call it with ShareX.exe -ColorPicker
I use it Regularly, so I said to order in AutoIt services
if you choose a color by double-clicking in scite on the hex color ,
you can then use get Get to get it, to see the color, or use Set to set
it, change it
with <-- button insert color name as comment, at the cursor position
PS:
for those who have a portable version of ShareX , don't forget to properly update line 30
LoadShareX("C:\Program Files\ShareX\ShareX.exe")
; https://www.autoitscript.com/forum/topic/209749-sharexexe-colorpicker/
;------------------------------------------------------------------------------ ; Title...........: CollorSX.au3 ; Description.....: ShareX.exe -ColorPicker ;------------------------------------------------------------------------------ #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #include <WindowsConstants.au3> #include <SendMessage.au3> #include <AutoItConstants.au3> #include <GUIConstantsEx.au3> #include <EditConstants.au3> #include <StringConstants.au3> Global $ClipBack, $ClipData, $hSciTE, $hCtrlHnd, $hShareX, $ShareX_Pos, $iState, $ColorName Global $hGhostGUI, $idButtonGet, $idButtonSet, $idColorName, $idButtonCopyTxt, $ActStatus, $TmpStatus, $HexColor If Not WinExists("[CLASS:SciTEWindow]") Then Exit EndIf ; copy selected text from SciTE $ClipBack = ClipGet() ; backup clip data $hSciTE = WinActivate("[CLASS:SciTEWindow]") $hCtrlHnd = ControlGetFocus($hSciTE) $hCtrlHnd = ControlGetHandle($hSciTE, '', $hCtrlHnd) _SendMessage($hCtrlHnd, $WM_COPY) $ClipData = ClipGet() LoadShareX("C:\Program Files\ShareX\ShareX.exe") $hShareX = WinWait("ShareX - Color picker") WinActivate($hShareX) ControlClick($hShareX, "", "[NAME:btnClipboardColorPicker]") $ColorName = ControlGetText($hShareX, "", "[NAME:lblNameValue]") $ShareX_Pos = WinGetPos($hShareX) ; get the ShareX win color $HexColor = PixelGetColor($ShareX_Pos[0] + 550, $ShareX_Pos[1] + 50) $HexColor = "0x" & Hex($HexColor, 6) ClipPut($ClipBack) ; Restore backup clip data ; Set the ShareX window as being ontop ConsoleWrite("$WinOnTop=" & WinSetOnTop($hShareX, "", $WINDOWS_ONTOP) & @CRLF) $hGhostGUI = GUICreate('GhostGUI', 210, 43, $ShareX_Pos[0] + 475, $ShareX_Pos[1] + 320, $WS_POPUP, $WS_EX_TOOLWINDOW, $hShareX) GUISetBkColor($HexColor) $idColorName = GUICtrlCreateEdit($ColorName, 3, 1, 180, 19, $ES_CENTER) GUICtrlSetColor(-1, 0xFFFFFF) GUICtrlSetBkColor(-1, 0x272727) $idButtonCopyTxt = GUICtrlCreateButton("<--", 183, 0, 24, 21) $idButtonGet = GUICtrlCreateButton("Get", 3, 23, 100, 20) $idButtonSet = GUICtrlCreateButton("Set", 107, 23, 100, 20) ; Display the GUI. GUISetState(@SW_SHOW, $hGhostGUI) WinActivate($hShareX) ;Yellow 0xFFFF00 ;Gray 0x7E7E7E ;Goldenrod 0xE39024 ;Lawn green 0x75DC19 ;Dark slate gray 0x063549 ;********************************************************************* While WinExists($hShareX) If Not WinExists($hSciTE) Then Exit EndIf ; Retrieve the state of the ShareX window $iState = WinGetState($hShareX) Switch $iState Case 7, 15 $ActStatus = @SW_SHOW Case 5, 23 $ActStatus = @SW_HIDE EndSwitch If $ActStatus <> $TmpStatus Then ;ConsoleWrite("$iState=" & $iState & @CRLF) GUISetState($ActStatus, $hGhostGUI) $TmpStatus = $ActStatus If $ActStatus = @SW_SHOW Then WinActivate($hShareX) $HexColor = "0x" & ControlGetText($hShareX, "", "[NAME:txtHex]") $ColorName = ControlGetText($hShareX, "", "[NAME:lblNameValue]") ConsoleWrite("# " & $HexColor & " ; " & $ColorName & @CRLF) GUICtrlSetData($idColorName, $ColorName) EndIf EndIf If WinActive($hShareX) Then $ShareX_Pos = WinGetPos($hShareX) WinMove($hGhostGUI, "", $ShareX_Pos[0] + 475, $ShareX_Pos[1] + 320) $ColorName = ControlGetText($hShareX, "", "[NAME:lblNameValue]") If $ColorName <> GUICtrlRead($idColorName) Then GUICtrlSetData($idColorName, $ColorName) EndIf EndIf Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $idButtonCopyTxt $ClipBack = ClipGet() ; backup clip data ClipPut(";" & GUICtrlRead($idColorName)) WinActivate($hSciTE) _SendMessage($hCtrlHnd, $WM_PASTE) Global $SpaceCnt = 2 StringReplace(ClipGet(), " ", " ", 0, $STR_CASESENSE) If @extended >= 1 Then $SpaceCnt += @extended EndIf Send("+^{LEFT " & $SpaceCnt & "}") ClipPut($ClipBack) ; Restore backup clip data Case $idButtonGet $ClipBack = ClipGet() ; backup clip data _SendMessage($hCtrlHnd, $WM_COPY) ControlClick($hShareX, "", "[NAME:btnClipboardColorPicker]") $HexColor = "0x" & ControlGetText($hShareX, "", "[NAME:txtHex]") $ColorName = ControlGetText($hShareX, "", "[NAME:lblNameValue]") ConsoleWrite("- Get " & $HexColor & " ; " & $ColorName & @CRLF) GUICtrlSetData($idColorName, $ColorName) ClipPut($ClipBack) ; Restore backup clip data Case $idButtonSet $ClipBack = ClipGet() ; backup clip data $HexColor = "0x" & ControlGetText($hShareX, "", "[NAME:txtHex]") $ColorName = ControlGetText($hShareX, "", "[NAME:lblNameValue]") ClipPut($HexColor) WinActivate($hSciTE) _SendMessage($hCtrlHnd, $WM_PASTE) Send("+^{LEFT}") ConsoleWrite("+ Set " & $HexColor & " ; " & $ColorName & @CRLF) GUICtrlSetData($idColorName, $ColorName) ClipPut($ClipBack) ; Restore backup clip data EndSwitch Sleep(10) WEnd ;********************************************************************* Exit ;---------------------------------------------------------------------------------------- Func LoadShareX($sFullPath) If Not WinExists("ShareX - Color picker") Then If Not FileExists($sFullPath) Then $sFullPath = @ScriptDir & "\ShareX.exe" If Not FileExists($sFullPath) Then $sFullPath = @ScriptDir & "\ShareX\ShareX.exe" If Not FileExists($sFullPath) Then Exit MsgBox(262144, StringTrimRight(@ScriptName, 4), "Kindly tell the script where to find ShareX.exe, bye now.", 10) Run('"' & $sFullPath & '" -ColorPicker') EndIf EndFunc ;==>LoadShareX
don't forget it's still under development !
Comments
Post a Comment