Sign in to follow this  
Followers 0
FinalVersion

Pixel Grab

5 posts in this topic




If you do mutiple grabs quickly, it returns the same value for all of them.

Looking at it I was able to come up with this:

HotKeySet("{F11}","grab")
HotKeySet("{ESC}","foo")

while 1
    sleep(100)
WEnd

func grab()
    $pos = MouseGetPos()
    $pixel_hex = PixelGetColor($pos[0],$pos[1])
    $pixel_dec = Dec($pixel_hex)
    MsgBox(0,"Retrieved",$pixel_dec)
    ToolTip($pixel_dec,$pos[0],$pos[1],"Result")
    Sleep(2000)
    ToolTip("")
EndFunc

Func foo()
    Exit
EndFunc

This code, no matter how fast you grab the pixel color, will always display the correct number and tooltip in the correct spot.

~corgano


0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e

Share this post


Link to post
Share on other sites

If you do mutiple grabs quickly, it returns the same value for all of them.

Looking at it I was able to come up with this:

HotKeySet("{F11}","grab")
HotKeySet("{ESC}","foo")

while 1
    sleep(100)
WEnd

func grab()
    $pos = MouseGetPos()
    $pixel_hex = PixelGetColor($pos[0],$pos[1])
    $pixel_dec = Dec($pixel_hex)
    MsgBox(0,"Retrieved",$pixel_dec)
    ToolTip($pixel_dec,$pos[0],$pos[1],"Result")
    Sleep(2000)
    ToolTip("")
EndFunc

Func foo()
    Exit
EndFunc

This code, no matter how fast you grab the pixel color, will always display the correct number and tooltip in the correct spot.

~corgano

Yeah well it took 5mins to make the script if that.

Share this post


Link to post
Share on other sites

I often use alot of different colors while making websites or playing around with pictures. I usually use something like paintshop to get the colorvalue and then copy/paste it, but I changes this script a little and made it, so I can just press F11 and the color is in the clipboard, ready for use ^_^

#include <WindowsConstants.au3>
#include <GUIConstants.au3>
Global $pixel_last
HotKeySet("{F11}","clip")
HotKeySet("{ESC}","endme")
#Region ### START Koda GUI section ### Form=
$Pixelgrab_form = GUICreate("Color Grab", 177, 85, 797, 354)
$font_group     = GUICtrlCreateGroup("Color", 12, 8, 153, 65)
$font_label     = GUICtrlCreateLabel("Label1", 50, 32, 90, 21)
GUICtrlSetFont(-1, 12, 800, 0, "Verdana")
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    sleep(100)
    Call("grab")
    
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

func grab()
    $pos = MouseGetPos()
    $pixel_hex = Hex(PixelGetColor($pos[0],$pos[1]), 6)
    
    If $pixel_last <> $pixel_hex Then
        GUICtrlSetData($font_label, "#" & $pixel_hex)
    EndIf
    $pixel_last = $pixel_hex
EndFunc

Func clip()
    ClipPut ("#" & $pixel_last)
EndFunc

Func endme()
    Exit
EndFunc

Software:Model Train Calculator (Screen)Autoit3 beginner!

Share this post


Link to post
Share on other sites

here is lil update it shows u coordinates too :D . Great job nice program

HotKeySet("{F11}","grab")

HotKeySet("{ESC}","foo")

while 1

sleep(100)

WEnd

func grab()

$pos = MouseGetPos()

$pixel_hex = PixelGetColor($pos[0],$pos[1])

$pixel_dec = Dec($pixel_hex)

MsgBox(0,"Retrieved",$pixel_dec &" ("&$pos[0]&","&$pos[1]&")")

ToolTip($pixel_dec,$pos[0],$pos[1],"Result")

Sleep(2000)

ToolTip("")

EndFunc

Func foo()

Exit

EndFunc


keywen.com

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0