ozmike Posted January 9, 2013 Share Posted January 9, 2013 (edited) Hi I have created this UDF to intercept mouse events so you can remap them ( including X buttons). - might work better on some windows versions 32/64 bit and some auto it versions. It treats mouse clicks like AutoIt hotkeys (which dosen't support mouse events). eg set up a hotkey for Right Click. _MouseTrapEvent("RClick", "_RClick", 1); single clicks Example events ; LClick - left button click (Primary) ; MClick - middle button click (Wheel click) ; RClick - right button click (Secondary) ; XClick1 - Xtra button 1 click (usually 'back navigaton') ; XClick2 - Xtra button 2 click (usually 'forward navigaton') ; double clicks ; LDClick - left button (Primary) ; MDClick - middle button (Wheel click) ; RDClick - right button (Secondary) ; XDClick1 - Xtra button 1 (usually 'back navigaton') ; XDClick2 - Xtra button 2 (usually 'forward navigaton') ; psuedo double clicks ('chords') - ; XClick12 - Xtra button 1&2 pressed at the same time. ; ; OTHER EVENTS you'll have to work out yourself eg mouse wheel scroll - see code. Borrows Heavily from JRowe's mouse event udf and (Mr)CreatoR's great work MouseSetEvent UDF's This UDF is not as comprehensive as MouseSetEvent but is simpler. The main difference to MouseSetEvent is this UDF - maps mouse events more simply than MouseSetEvent - You don't have to worry about button down and up events (which can be a pitfall with MouseSetEvent ). - Handles X buttons on side of mouse. ($WM_XBUTTONUP). - may be slower (does a lot of string handling which could be better) - might work better on some windows versions 32/64 bit and some auto it versions. - is global can't be limited to one window. - code is simpler to follow imho eg. The code needs to be optimised. Examples they use a tool tip UDF which might require at least ie8 or remove the tool tips from the example if it don't work. Enjoy V2 Left and Middle double click now work. Also note if you register a double click , the single click event will be blocked (my apols) However, you can still register the single click, and do something if you want. MouseTrapEventV2.zip MouseTrapEvent.zip 7.39KB 342 downloads Edited July 31, 2014 by ozmike mesale0077 and IgImAx 2 Link to comment Share on other sites More sharing options...
b3vad Posted March 7, 2015 Share Posted March 7, 2015 I like how it's simple to and straight to point. can you take a look at this code and tell me what I've done wrong? it woks fine without MouseClick("left") but after I add this line it runs the function nonstop. thank you. #include <MouseTrapEvent.au3> _BlockMouseClicksInput(1) while 1 sleep(500) WEnd Func _BlockMouseClicksInput($iOpt = 1) If $iOpt = 1 Then _MouseTrapEvent("XClick1", "_XClick1" ); click x1 - intercept user defined block Else _MouseTrapEvent("XClick1") ; deregister EndIf EndFunc func _XClick1() MouseClick("left") sleep(100) Send("{DOWN}") sleep(100) Send("{ENTER}") Sleep(100) Send("{DOWN}") sleep(100) Send("{ENTER}") endfunc [center]My language! gets the job done![/center] Link to comment Share on other sites More sharing options...
ozmike Posted March 24, 2015 Author Share Posted March 24, 2015 Here is a work around - seems to be a bug? Deregister events and then re-register just before you leave.Seems you can't send a mouse click within a mouse trap! hope it helps. #include <MouseTrapEvent.au3> _BlockMouseClicksInput(1) while 1 sleep(500) WEnd Func _BlockMouseClicksInput($iOpt = 1) If $iOpt = 1 Then _MouseTrapEvent("XClick1", "_XClick1" ); click x1 - intercept user defined block Else _MouseTrapEvent("XClick1") ; deregister EndIf EndFunc func _XClick1() _BlockMouseClicksInput(0) MouseClick("left") sleep(100) Send("{DOWN}") sleep(100) Send("{ENTER}") Sleep(100) Send("{DOWN}") sleep(100) Send("{ENTER}") _BlockMouseClicksInput(1) endfunc 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