supersonic Posted October 23, 2009 Share Posted October 23, 2009 (edited) Hi! I'm trying to trigger single and double clicks in edit controls... No luck so far... Is there a way to handle it with the help of $WM_NOTIFY? Here's some sample code: GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY") Func _WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg, $iwParam ; $ilParam ; <...> Local $hWndFrom, _ $hWndCtrl = $aTab2E0, _ $iCode, _ $tInfo, _ $tNMHDR ; <...> If Not IsHWnd($aTab2E0) Then $hWndCtrl = GUICtrlGetHandle($aTab2E0) ; <...> $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $iCode = DllStructGetData($tNMHDR, "Code") $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) ; <...> Switch $hWndFrom Case $hWndCtrl Switch $iCode Case $NM_DBLCLK Switch $hWndFrom Case $hWndCtrl MsgBox(0, "", "test", 0) EndSwitch EndSwitch EndSwitch ; <...> Return $GUI_RUNDEFMSG EndFunc Anyone any idea? Greets, -supersonic. Edited October 23, 2009 by supersonic Link to comment Share on other sites More sharing options...
Authenticity Posted October 23, 2009 Share Posted October 23, 2009 Seems like the control suppresses this message by handling the message and not calling the default window procedure. #include <Constants.au3> #include <GUIConstantsEx.au3> #include <WinAPI.au3> If Not IsDeclared("WM_LBUTTONDBLCLK") Then Global Const $WM_LBUTTONDBLCLK = 0x0203 Local $hGUI = GUICreate("Title", 200, 200) Local $Edit = GUICtrlCreateEdit("Text", 20, 20, 160, 160) Local $hEdit = GUICtrlGetHandle($Edit) Local $hFunc, $hOldProc $hFunc = DllCallbackRegister("_EditProc", "lresult", "hwnd;uint;wparam;lparam") $hOldProc = _WinAPI_SetWindowLong($hEdit, $GWL_WNDPROC, DllCallbackGetPtr($hFunc)) GUISetState() Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() DllCallbackFree($hFunc) Exit Func _EditProc($hWnd, $iMsg, $iwParam, $ilParam) If $iMsg = $WM_LBUTTONDBLCLK Then _ ConsoleWrite("Left double click" & @CRLF) Return _WinAPI_CallWindowProc($hOldProc, $hEdit, $iMsg, $iwParam, $ilParam) EndFunc ..until you find a workaround. Link to comment Share on other sites More sharing options...
supersonic Posted October 23, 2009 Author Share Posted October 23, 2009 (edited) Thank you. I'm getting an error message when trying to run the script: M:\test.au3 (12) : ==> Badly formatted "Func" statement.: $hFunc = DllCallbackRegister("_EditProc", "lresult", "hwnd;uint;wparam;lparam") Currently I'm using AutoIt 3.3.0.0. Any idea? Seems like the control suppresses this message by handling the message and not calling the default window procedure. #include <Constants.au3> #include <GUIConstantsEx.au3> #include <WinAPI.au3> If Not IsDeclared("WM_LBUTTONDBLCLK") Then Global Const $WM_LBUTTONDBLCLK = 0x0203 Local $hGUI = GUICreate("Title", 200, 200) Local $Edit = GUICtrlCreateEdit("Text", 20, 20, 160, 160) Local $hEdit = GUICtrlGetHandle($Edit) Local $hFunc, $hOldProc $hFunc = DllCallbackRegister("_EditProc", "lresult", "hwnd;uint;wparam;lparam") $hOldProc = _WinAPI_SetWindowLong($hEdit, $GWL_WNDPROC, DllCallbackGetPtr($hFunc)) GUISetState() Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() DllCallbackFree($hFunc) Exit Func _EditProc($hWnd, $iMsg, $iwParam, $ilParam) If $iMsg = $WM_LBUTTONDBLCLK Then _ ConsoleWrite("Left double click" & @CRLF) Return _WinAPI_CallWindowProc($hOldProc, $hEdit, $iMsg, $iwParam, $ilParam) EndFunc ..until you find a workaround. Edited October 23, 2009 by supersonic Link to comment Share on other sites More sharing options...
Authenticity Posted October 23, 2009 Share Posted October 23, 2009 (edited) Sorry, I'm 3.3.0.0 so convert the necessary error to your version. 3.3.1.3?Edit:(\/ ) (oO ) (")(") Edited October 23, 2009 by Authenticity Link to comment Share on other sites More sharing options...
supersonic Posted October 23, 2009 Author Share Posted October 23, 2009 Okay... I forgot to add the function called "_EditProc()"... The script starts but always ends with this: !>21:31:02 AutoIT3.exe ended.rc:-1073741819 Link to comment Share on other sites More sharing options...
martin Posted October 23, 2009 Share Posted October 23, 2009 Okay... I forgot to add the function called "_EditProc()"...The script starts but always ends with this:!>21:31:02 AutoIT3.exe ended.rc:-1073741819Works ok for me using XP and AutoIt 3.3.00 or Beta 3.3.1.3.What OS and AutoIt versions are you using supersonic? Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
supersonic Posted October 23, 2009 Author Share Posted October 23, 2009 AI V3.3.0.0 or 3.3.1.3. Windows XP Prof. (Admin mode).Works ok for me using XP and AutoIt 3.3.00 or Beta 3.3.1.3.What OS and AutoIt versions are you using supersonic? Link to comment Share on other sites More sharing options...
martin Posted October 23, 2009 Share Posted October 23, 2009 AI V3.3.0.0 or 3.3.1.3. Windows XP Prof. (Admin mode).I've tried on XP Home and Professional and no problem so I don't know why it doesn't work for you. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
supersonic Posted October 24, 2009 Author Share Posted October 24, 2009 Ohhh... Now it is working... Was my fault... Thank for your help...I've tried on XP Home and Professional and no problem so I don't know why it doesn't work for you. Link to comment Share on other sites More sharing options...
supersonic Posted October 24, 2009 Author Share Posted October 24, 2009 The sample provided Authenticity works pretty well for double clicks... Is there a way to modify it for single clicks? Link to comment Share on other sites More sharing options...
Authenticity Posted October 24, 2009 Share Posted October 24, 2009 Just process the $WM_LBUTTONDOWN also. The problem is that $WM_LBUTTONDOWN or $WM_LBUTTONUP are posted in pairs and twice each prior to a $WM_LBUTTONDBLCLK message, I guess. So you should implement a sophisticated mechanism to differentiate a one click event from double click event. You can achieve that by first reading the value of this function to determine the what is the interval that a sequence of mouse clicks are considered a double click, then work with TimerInit() and TimerDiff() with global variables, as of time being. Link to comment Share on other sites More sharing options...
supersonic Posted November 10, 2009 Author Share Posted November 10, 2009 Thank you so far for your help!Just process the $WM_LBUTTONDOWN also. The problem is that $WM_LBUTTONDOWN or $WM_LBUTTONUP are posted in pairs and twice each prior to a $WM_LBUTTONDBLCLK message, I guess. So you should implement a sophisticated mechanism to differentiate a one click event from double click event. You can achieve that by first reading the value of this function to determine the what is the interval that a sequence of mouse clicks are considered a double click, then work with TimerInit() and TimerDiff() with global variables, as of time being. 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