Jump to content

Mouse Button as HotKey


 Share

Recommended Posts

I have been searching the forum for two hours, and I can't seem to find the answer I need.

I'd like to have a script that can detect when the right mouse button is clicked and perform a function.

This should work just like a HotKey.

I have written many scripts in AutoIt V2 in the past, but I am new to V3.

I have most of my script working including the function that will be run when the button is clicked. I have tested it with a regular HotKeySet. HotKeySet does not appear to have an option for the mouse buttons.

Am I missing something obvious?

Link to comment
Share on other sites

I have been searching the forum for two hours, and I can't seem to find the answer I need.

I'd like to have a script that can detect when the right mouse button is clicked and perform a function.

This should work just like a HotKey.

I have written many scripts in AutoIt V2 in the past, but I am new to V3.

I have most of my script working including the function that will be run when the button is clicked. I have tested it with a regular HotKeySet. HotKeySet does not appear to have an option for the mouse buttons.

Am I missing something obvious?

maybe u can do like

While 1

if _isPressed(MouseButton) then Function()

EndIf

Wend

?

Edited by CHRIS95219
Link to comment
Share on other sites

here is an example code...

#include <misc.au3>

While 1
If _isPressed("01") then _Mouseonclick()
Else
;;;
EndIf
Wend

Func _Mouseonclick()
MsgBox(0, "Example", "Example")
EndFunc
Thanks for the help.

I can make that work for me, but I would have really liked it to work like a HotKey and intercept the mouse click.

Something like HotKeySet({RightMouseClick},"_Mouseonclick")

Link to comment
Share on other sites

I went with this so I could exit the script if the prgram window was closed.

I also set a hot key for {ESC} to exit the script as well.

While WinExists($window)
        if $reload <> "no" then
            If _isPressed("02") then 
                _Mouseonclick()
            EndIf
        Endif
    Wend

Thanks again for the help.

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...