Reputation: 1
I want my code to be able to register if the mouse is clicked, and do something when that happens, but also to be able to register if the mouse is held down and not interrupt the mouse being held down if that is the case. For example,
If AutoCAD is open
If mbutton is clicked
click the escape key
If mbutton is held down
be able to use the mbutton held down as usual
End
I've tried a couple of different ways to do this but I don't have the knowledge to do this exactly. I've got the "If AutoCAD is open", and the "click the escape key" parts down, just not the "use the mbutton as normal if held down part"
Thanks for any help you can provide!
Upvotes: 0
Views: 283
Reputation: 2999
This was a bit of a tricky one. Change the #IfWinExist
line accordingly. You can adjust the duration to be what you would consider "holding" MButton
SetTitleMatchMode, 2
#IfWinExist AutoCAD
~MButton::
duration := 100
start := A_TickCount
While(GetKeyState("MButton"))
{
if ((A_TickCount - start) > duration)
{
KeyWait, MButton
Send {MButton Up}
Return
}
}
Send, {Escape}
Return
#IfWinExist AutoCAD
Upvotes: 2
Reputation: 10822
If I understand you right, you are searching for the UP
keyword:
The word UP may follow the name of a hotkey to cause the hotkey to fire upon release of the key rather than when the key is pressed down.
#if autocad()
MButton Up::
send {escape}
return
#if
autocad() {
return true
}
Upvotes: 0