Sign in to follow this  
Followers 0
Erik Ruud

Mouse Button as HotKey

7 posts in this topic

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?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

look in beta help file for _IsPressed

02 = right mouse button

Edited by peter1234

Share this post


Link to post
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

Share this post


Link to post
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")

Share this post


Link to post
Share on other sites

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")

np. I'll try to work on making something like that... if i can... lol.

Share this post


Link to post
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.

Share this post


Link to post
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
Sign in to follow this  
Followers 0