Terenz Posted June 27, 2016 Share Posted June 27, 2016 Hello. With an autoit GUI there are several way for intercept a mouse click ( _IsPressed, $WM_LBUTTONDOWN, $GUI_EVENT_PRIMARYDOWN) but i don't have found nothing to disable a right-left click inside the GUI-Control except using low level hook. I'm miss something or there isn't any "classic" way? Thanks Nothing is so strong as gentleness. Nothing is so gentle as real strength Link to comment Share on other sites More sharing options...
LarsJ Posted June 28, 2016 Share Posted June 28, 2016 Subclassing (read and process Windows messages before they reach the destination control or window) is a common way. Here (the example for GUICtrlCreateEdit in the Help file) right click is canceled in the Edit control and no context menu shows up: expandcollapse popup#include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPIShellEx.au3> Example() Func Example() GUICreate("My GUI edit") ; will create a dialog box that when displayed is centered Local $idMyedit = GUICtrlCreateEdit("First line" & @CRLF, 176, 32, 121, 97, $ES_AUTOVSCROLL + $WS_VSCROLL) Local $hMyedit = GUICtrlGetHandle( $idMyedit ) ; Subclassing Edit control Local $pEditCallback = DllCallbackGetPtr( DllCallbackRegister( "EditCallback", "lresult", "hwnd;uint;wparam;lparam;uint_ptr;dword_ptr" ) ) _WinAPI_SetWindowSubclass( $hMyedit, $pEditCallback, 1, 0 ) ; $iSubclassId = 1, $pData = 0 GUISetState(@SW_SHOW) Send("{END}") ; will be append dont' forget 3rd parameter GUICtrlSetData($idMyedit, "Second line", 1) ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd GUIDelete() EndFunc ;==>Example Func EditCallback( $hWnd, $iMsg, $wParam, $lParam, $iSubclassId, $pData ) ; If $iMsg <> $WM_RBUTTONUP then call next function in subclass chain (this forwards messages to Edit control) If $iMsg <> $WM_RBUTTONUP Then Return DllCall( "comctl32.dll", "lresult", "DefSubclassProc", "hwnd", $hWnd, "uint", $iMsg, "wparam", $wParam, "lparam", $lParam )[0] Return 0 ; If $iMsg = $WM_RBUTTONUP then cancel the message by returning 0 EndFunc pixelsearch 1 Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
Terenz Posted June 28, 2016 Author Share Posted June 28, 2016 (edited) The problem of subclassing is if i have example 10 controls i need to do 10 _WinAPI_SetWindowSubclass, right? Is strange that we can intercept the message using GUIRegisterMsg or GUIGetMsg but we can't stop the message in any native way. Edited June 28, 2016 by Terenz Nothing is so strong as gentleness. Nothing is so gentle as real strength Link to comment Share on other sites More sharing options...
LarsJ Posted June 28, 2016 Share Posted June 28, 2016 Yes, but if it's the same controls (eg. Edit controls) you can use the same callback function. You can use GUIRegisterMsg to cancel many Windows messages. But not the mouse messages because they are used by the internal AutoIt code. Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
EmilyLove Posted June 28, 2016 Share Posted June 28, 2016 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