1 [AutoIt] - Pixel Grab Modification Thu Apr 14, 2011 4:25 am
The Professor
Contributor
So I decided to modify the open-source pixel grab program available on Cake-kun.com. I actually use this program because it's simple and convenient.
All I did was pretty much make it more efficient. This was made on Linux and has not been tested, so I'd like CT to personally test it and give feedback. It would be greatly appreciated.
Anyway, here it is.
Use the F8 hotkey for help display.
Also, if anyone would like a compiled version, please specify so on this thread.
All I did was pretty much make it more efficient. This was made on Linux and has not been tested, so I'd like CT to personally test it and give feedback. It would be greatly appreciated.
Anyway, here it is.
- Code:
; Modified by Cake & Protozoid
#NoTrayIcon
#AutoIt3Wrapper_Icon=..\Icons\cake1.ico
#AutoIt3Wrapper_Outfile=..\Color Grab.exe
#include <GUIConstants.au3>
#include <Color.au3>
#include <EditConstants.au3>
#include <WindowsConstants.au3>
Global $Pixel_Last, $Pixel_RGB, $hForm
HotKeySet("{F7}", "start")
HotKeySet("{F8}", "help")
HotKeySet("{F9}", "clipHex")
HotKeySet("{F10}", "clipRGB")
HotKeySet("{ESC}", "close")
AutoItSetOption("GuiOnEventMode", 1)
GUICreate("Color Grab", 337, 160, 797, 354)
GUICtrlCreateGroup("Hex Color", 12, 8, 153, 65)
$HexLabel = GUICtrlCreateLabel("N/A", 50, 32, 90, 21)
GUICtrlCreateGroup("RGB Color", 12, 80, 153, 65)
$RGBLabel = GUICtrlCreateLabel("N/A", 50, 102, 90, 21)
$showcolor = GUICtrlCreateGraphic(175, 17, 153, 126)
GUICtrlSetBkColor(-1, 0x000000)
GUISetOnEvent($GUI_EVENT_CLOSE, "close")
GUISetState()
While 1
Sleep(10)
WEnd
Func grab()
$pos = MouseGetPos()
$pixel_hex = Hex(PixelGetColor($pos[0], $pos[1]), 6)
$Pixel_RGB = __ColorGetRGB("0x" & $pixel_hex)
If $Pixel_Last <> $pixel_hex Then
GUICtrlSetData($HexLabel, "#" & $pixel_hex)
GUICtrlSetData($RGBLabel, $Pixel_RGB)
GUICtrlSetBkColor($showcolor, "0x" & $pixel_hex)
EndIf
$Pixel_Last = $pixel_hex
EndFunc ;==>grab
Func __ColorGetRGB($nColor)
Return _ColorGetRed($nColor) & " " & _ColorGetGreen($nColor) & " " & _ColorGetBlue($nColor)
EndFunc ;==>__ColorGetRGB
Func start()
AdlibRegister("grab", 50)
EndFunc ;==>start
Func help()
$hForm = GUICreate("Color Grab | Help", 412, 172, 192, 114)
$hEdit = GUICtrlCreateEdit("", 0, 0, 409, 137, BitOR($ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN, $WS_HSCROLL, $WS_VSCROLL))
GUICtrlSetData(-1, StringFormat("To use, hover your mouse over the pixel (color) you want to grab. \r\nThen press F9 to copy the hex of the pixel to the clipboard, or you can grab the \r\npixel in an alternative format by using F10.\r\n\r\nHere are all available functions on this program in hotkey format:\r\n\r\nF7 - Start; Starts the pixel grabbing.\r\nF8 - Help; Opens the help dialog.\r\nF9 - Pixel to Clipboard; Copies said pixel to your clipboard in hex format.\r\nF10 - Pixel to Clipboard (alternative); Copies said pixel to your clipboard in an alternative format.\r\nEsc - Terminate; Closes the Pixel Grab program."))
$hBtn = GUICtrlCreateButton("Close", 168, 144, 75, 25, $WS_GROUP)
GUISetState(@SW_SHOW)
GUISetOnEvent($GUI_EVENT_CLOSE, "delete")
GUISetOnEvent($hBtn, "delete")
EndFunc ;==>help
Func delete()
GUIDelete($hForm)
EndFunc ;==>delete
Func clipHex()
ClipPut("#" & $Pixel_Last)
EndFunc ;==>clipHex
Func clipRGB()
ClipPut($Pixel_RGB)
EndFunc ;==>clipRGB
Func close()
Exit
EndFunc ;==>close
Use the F8 hotkey for help display.
Also, if anyone would like a compiled version, please specify so on this thread.
Last edited by Protozoid on Thu Apr 14, 2011 8:23 pm; edited 1 time in total