alfonso Posted May 21, 2009 Share Posted May 21, 2009 Is there any easy way to get/simulate events ButtonPress and ButtonRelease? Thanks in advance, Alfonso Link to comment Share on other sites More sharing options...
Authenticity Posted May 21, 2009 Share Posted May 21, 2009 expandcollapse popup#include <Constants.au3> #include <WinAPI.au3> Global Const $WM_MOUSEMOVE = 0x0200 Global Const $WM_LBUTTONDOWN = 0x0201 Global Const $WM_LBUTTONUP = 0x0202 Global $hGUI Global $Button, $hButton Global $hFunc, $pFunc Global $hOldProc Global $fPressed = False $hFunc = DllCallbackRegister('ButtonProc', 'int', 'hwnd;uint;wparam;lparam') $pFunc = DllCallbackGetPtr($hFunc) $hGUI = GUICreate('Test', 100, 100) $Button = GUICtrlCreateButton('Text', 20, 40, 60, 23) $hButton = GUICtrlGetHandle(-1) $hOldProc = _WinAPI_GetWindowLong($hButton, $GWL_WNDPROC) _WinAPI_SetWindowLong($hButton, $GWL_WNDPROC, $pFunc) GUISetState() Do Until GUIGetMsg() = -3 GUIDelete() DllCallbackFree($hFunc) Exit Func ButtonProc($hwnd, $iMsg, $iwParam, $ilParam) Switch $iMsg Case $WM_LBUTTONDOWN ConsoleWrite('Pressed' & @LF) $fPressed = True Case $WM_LBUTTONUP ConsoleWrite('Release' & @LF) $fPressed = False Case $WM_MOUSEMOVE If $fPressed Then ConsoleWrite('Still pressed' & @LF) EndSwitch Return _WinAPI_CallWindowProc($hOldProc, $hwnd, $iMsg, $iwParam, $ilParam) EndFunc Link to comment Share on other sites More sharing options...
alfonso Posted May 21, 2009 Author Share Posted May 21, 2009 Thanks Authenticity. It works great! Link to comment Share on other sites More sharing options...
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