Jump to content

MouseTrapEvent UDF


ozmike
 Share

Recommended Posts

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

stuffit.gif  MouseTrapEvent.zip   7.39KB   342 downloads

Edited by ozmike
Link to comment
Share on other sites

  • 2 years later...

I like how it's simple to and straight to point.  :thumbsup: 
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

  • 3 weeks later...

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...