sipar Posted March 10, 2009 Posted March 10, 2009 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.
Authenticity Posted March 10, 2009 Posted March 10, 2009 expandcollapse popupDim $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 ?
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now