Would you like to react to this message? Create an account in a few clicks or log in to continue.

You are not connected. Please login or register

View previous topic View next topic Go down  Message [Page 1 of 1]

1[AutoIt] - Pixel Grab Modification  Empty [AutoIt] - Pixel Grab Modification Thu Apr 14, 2011 4:25 am

The Professor

The Professor
Contributor
Loading
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.

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

2[AutoIt] - Pixel Grab Modification  Empty Re: [AutoIt] - Pixel Grab Modification Thu Apr 14, 2011 10:08 am

The Anonymous

The Anonymous
Top Dog
Loading
I am new to this so where does the words in the box go?

3[AutoIt] - Pixel Grab Modification  Empty Re: [AutoIt] - Pixel Grab Modification Thu Apr 14, 2011 8:11 pm

Thomas

Thomas
Admin
Loading
Hawk its Autoit; it's a program.

4[AutoIt] - Pixel Grab Modification  Empty Re: [AutoIt] - Pixel Grab Modification Thu Apr 14, 2011 8:18 pm

The Anonymous

The Anonymous
Top Dog
Loading
I don't know how to program. I want to learn how to script on Gaia.

5[AutoIt] - Pixel Grab Modification  Empty Re: [AutoIt] - Pixel Grab Modification Thu Apr 14, 2011 8:20 pm

The Professor

The Professor
Contributor
Loading
Raze wrote:Hawk its Autoit; it's a program.

That's not necessarily what he was asking.
/facepalm

@Hawk, if you're wanting to learn what programming is, now is the time to start using proper terminology. Those words, as you said, aren't just words. They're code. Code is generally used by a programming language. That programming language interprets this code then translates it to machine language.

Also, this thread isn't the appropriate place for me to explain how exactly "those words" work. But I can maybe make a tutorial or two when I have spare time. But if you want, I can compile this code into a standalone executable so you can use it without any programming intervention.

And a side note - This has nothing to do with Gaia whatsoever.

6[AutoIt] - Pixel Grab Modification  Empty Re: [AutoIt] - Pixel Grab Modification Thu Apr 14, 2011 8:24 pm

The Anonymous

The Anonymous
Top Dog
Loading
Oh okay thanks anyway.

7[AutoIt] - Pixel Grab Modification  Empty Re: [AutoIt] - Pixel Grab Modification Thu Apr 14, 2011 8:29 pm

The Professor

The Professor
Contributor
Loading
No problem. But I plan to compile this later because I plan to mod this a couple more times before I'm completely satisfied with it. I'm usually repetitive about things I'm interested in so.

@topic, there will be updates to this. So for those of you who are interested, stay tuned.

8[AutoIt] - Pixel Grab Modification  Empty Re: [AutoIt] - Pixel Grab Modification Fri Apr 22, 2011 7:27 pm

Guest

avatar
Guest
Loading
What does it do?

Sponsored content


Loading

View previous topic View next topic Back to top  Message [Page 1 of 1]

Related topics

Permissions in this forum:
You cannot reply to topics in this forum