Jump to content
Sign in to follow this  
sipar

Need to update label on move mouse

Recommended Posts

sipar

Hello. Im new with AutoIt. Im making some app. and i want help.

That app. will show current mouse position in labels and pixel color under mouse in label.

Here's code:

#include <GuiConstantsEx.au3>

GuiCreate("Title", 300, 200)
GuiSetState()
$pos = MouseGetPos()
$color = PixelGetColor($pos[0],$pos[1])
GuiCtrlCreateLabel(hex($color,6),50,60,50,20)
GuiCtrlCreateLabel($pos[0],100,60,40,40)
GuiCtrlCreateLabel($pos[1],150,60,40,40)

While GuiGetMsg() <> $GUI_EVENT_CLOSE
WEnd

Yeah it works, but i want to update these labels on mouse move. When i add while then labels blinks.

How to do that? Help please.

Share this post


Link to post
Share on other sites
Authenticity

Dim $hUser = DllOpen('user32.dll')
Dim $hGdi = DllOpen('gdi32.dll')

HotKeySet('{ESC}', '_EXIT')
AdlibEnable('_Search', 100)

While 1
    Sleep(20)
WEnd

Func _EXIT()
    AdlibDisable()
    DllClose($hGdi)
    DllClose($hUser)
    Exit
EndFunc

Func _Search()
    Local $Pos = MouseGetPos()
    Local $hdc = _GetWindowDC(0)
        If $hdc = -1 Then Return
    Local $iPixel = _GetPixel($hdc, $Pos[0], $Pos[1])
    
    ToolTip('iX: ' & $Pos[0] & @TAB & 'iY: ' & $Pos[1] & @LF & 'Pixel color: 0x' & Hex($iPixel, 6), _
            @DesktopWidth-120, 0)
EndFunc
    
    

Func _GetWindowDC($hwnd)
    Local $Ret
    ;If IsHWnd Then
        $Ret = DllCall($hUser, 'ptr', 'GetWindowDC', 'ptr', $hwnd)
    ;Else
        ;$Ret = DllCall($hUser, 'ptr', 'GetWindowDC', 'int', $hwnd)
    ;EndIf
    
    If Not @error Then Return $Ret[0]
    Return SetError(-1, 0, -1)

EndFunc


Func _GetPixel($hDC, $iX, $iY)
    Local $Ret = DllCall($hGdi, 'dword', 'GetPixel', 'ptr', $hDC, 'int', $iX, 'int', $iY)
    Return $Ret[0]
    
EndFunc

?

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.