Mytheral
Mytheral

Reputation: 3959

AHK - How to hold a macro while Physical Key depressed

What I want to do is this:

Numpad3::
    if(not GetKeyState("Shift" , "P") and not GetKeyState("RButton" , "P"))
    {
        SendInput {Shift down}
        Sleep, 33
        Click down right
    }
Return

Numpad3 Up::
    Sleep, 100
    Click up right
    Sleep, 33
    SendInput {Shift up}
Return

But for some reason it isn't canceling when I let the button up. :(

Upvotes: 0

Views: 264

Answers (1)

Tahir Hassan
Tahir Hassan

Reputation: 5817

I would suggest to use Send {RButton Down} (or Up) to send the right mouse click, instead of Click up right.

Also, you don't want to be sending random Sleep's if they are not really necessary, as it creates lag and makes the script inelegant and potentially unreadable.

Here is code which sends Control instead of RButton but it's only so I can test it within Notepad++.

Just replace Control with RButton and have a go:

*NumpadPgDn::
*Numpad3::
    Send {Shift Down}{Control Down}
return

*NumpadPgDn Up::
*Numpad3 Up::
    Send {Shift Up}{Control Up}
return

Upvotes: 1

Related Questions