inm101 Posted January 13, 2011 Posted January 13, 2011 In VB, I can make a button only react to a "Mouse Down" event where the user has to use a mouse click to activate a button on a form. Does AutoIT have a similar function where I can make a button work only if it's clicked on by the mouse rather than by the enter key on the keyboard?
Varian Posted January 13, 2011 Posted January 13, 2011 (edited) Melba23 shows us an excellent example What it does is remove the tab stop from button 2 so the only way to click it is via the mouse. I modified his original code to better show the results. The relevant line for removing the Tab Stop begins with _WinAPI_SetWindowLong#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Constants.au3> #include <WinAPI.au3> Local $Button1, $button2, $Button3 $hGUI = GUICreate("Test", 500, 500) GUICtrlCreateLabel("One", 10, 10, 50, 20) GUICtrlCreateLabel("Two", 10, 30, 50, 20) GUICtrlCreateLabel("Three", 10, 50, 50, 20) $Button1 = GUICtrlCreateButton("One", 10, 100, 80, 30) $button2 = GUICtrlCreateButton("Two", 10, 140, 80, 30) _WinAPI_SetWindowLong(GUICtrlGetHandle(-1), $GWL_STYLE, BitAND(_WinAPI_GetWindowLong(GUICtrlGetHandle(-1), $GWL_STYLE), BitNOT($WS_TABSTOP))) $Button3 = GUICtrlCreateButton("Three", 10, 180, 80, 30) GUISetState() While 1 $Msg = GUIGetMsg() Switch $Msg Case $GUI_EVENT_CLOSE Exit Case 3 to 8 $sText = ControlGetText($hGUI, '', $msg) MsgBox(64, 'Button Hit', 'You clicked ' & $sText & @LF & ' CtrlID = ' & $msg, 5) EndSwitch WEndEDIT: Make sure you don't have a Key combo assinged to it (with an Ampersand) likeGUICtrlCreateButton("B&utton 1", 30, 20, 120, 40) Edited January 13, 2011 by Varian
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