Rodger Posted August 10, 2011 Share Posted August 10, 2011 Hello, Is there a way to turn the mousebuttons off ONLY when de mousepointer is within the GUI of the running AutoIt program created ? Thks. Link to comment Share on other sites More sharing options...
lordicast Posted August 10, 2011 Share Posted August 10, 2011 (edited) You could get the Coords. of your window then get the Coords. of your mouse and Set a action for the mouse clicks when then meet. Or just set action for the mouse click when your Guis window is active. I would just hide the mouse when my window is active personally. with GUISetCursor ( [cursorID [, override [, winhandle]]] ) CursorId = 16 will hide the mouse cursor. Lookup Functions MouseDown MouseGetPos MouseCoordMode Edited August 10, 2011 by lordicast [Cheeky]Comment[/Cheeky] Link to comment Share on other sites More sharing options...
wakillon Posted August 10, 2011 Share Posted August 10, 2011 You could get the Coords. of your window then get the Coords. of your mouse and Set a action for the mouse clicks when then meet. Or just set action for the mouse click when your Guis window is active. I would just hide the mouse when my window is active personally. with GUISetCursor ( [cursorID [, override [, winhandle]]] ) CursorId = 16 will hide the mouse cursor. Lookup Functions MouseDown MouseGetPos MouseCoordMode hide the mouse cursor doesn't disable mouse clicks. AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Link to comment Share on other sites More sharing options...
wakillon Posted August 10, 2011 Share Posted August 10, 2011 (edited) Try this expandcollapse popup#include <MouseSetOnEvent_UDF.au3> Global $_GuiHandle = GUICreate ( '' ) $Button_1 = GUICtrlCreateButton ( "Button1", 10, 30, 100 ) GUISetState ( ) $_MouseOverOld=0 While 1 $_Msg = GUIGetMsg ( ) Switch $_Msg Case -3 Exit Case $Button_1 ConsoleWrite ( "Button1" & @Crlf ) EndSwitch $_MouseOver = _IsMouseOverWindow ( $_GuiHandle, 1 ) If $_MouseOver <> $_MouseOverOld Then Switch $_MouseOver Case 1 ;GUISetCursor ( 16, 1, $_GuiHandle ) _BlockMouseClicksInput ( 0 ) Case Else ; GUISetCursor ( 2, 1, $_GuiHandle ) _BlockMouseClicksInput ( 1 ) EndSwitch $_MouseOverOld = $_MouseOver EndIf WEnd Func _BlockMouseClicksInput ( $iOpt=0 ) If $iOpt = 0 Then _MouseSetOnEvent ( $MOUSE_PRIMARYUP_EVENT, "__Dummy" ) _MouseSetOnEvent ( $MOUSE_PRIMARYDOWN_EVENT, "__Dummy" ) _MouseSetOnEvent ( $MOUSE_SECONDARYUP_EVENT, "__Dummy" ) _MouseSetOnEvent ( $MOUSE_SECONDARYDOWN_EVENT, "__Dummy" ) Else _MouseSetOnEvent ( $MOUSE_PRIMARYUP_EVENT ) _MouseSetOnEvent ( $MOUSE_PRIMARYDOWN_EVENT ) _MouseSetOnEvent ( $MOUSE_SECONDARYUP_EVENT ) _MouseSetOnEvent ( $MOUSE_SECONDARYDOWN_EVENT ) EndIf EndFunc ;==> _BlockMouseClicksInput ( ) Func _IsMouseOverWindow ( $_GuiHwnd, $_Active=0 ) $_WinGetPos = WinGetPos ( $_GuiHwnd ) If @error Then Return 0 $_MouseGetPos = MouseGetPos ( ) If @error Then Return 0 If $_MouseGetPos[0] > $_WinGetPos[0] And $_MouseGetPos[0] < $_WinGetPos[0]+$_WinGetPos[2] And _ $_MouseGetPos[1] > $_WinGetPos[1] And $_MouseGetPos[1] < $_WinGetPos[1]+$_WinGetPos[3] Then If $_Active Then $_WinState = WinGetState ( $_GuiHwnd ) If BitAnd ( $_WinState, 8 ) Then Return 1 Else Return 0 EndIf Else Return 1 EndIf EndIf EndFunc ;==> _IsMouseOverWindow ( ) Edited August 10, 2011 by wakillon AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Link to comment Share on other sites More sharing options...
Rodger Posted August 10, 2011 Author Share Posted August 10, 2011 Thank you all for your feedback. I hope this will work Link to comment Share on other sites More sharing options...
wakillon Posted August 10, 2011 Share Posted August 10, 2011 Thank you all for your feedback. I hope this will work It works. AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts 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