AHK - 如何在按下物理键时按住宏

AHK - How to hold a macro while Physical Key depressed

我想做的是:

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

但出于某种原因,当我松开按钮时它并没有取消。 :(

我建议使用 Send {RButton Down}(或 Up)发送鼠标右键单击,而不是 Click up right

此外,您不希望发送随机 Sleep,如果它们不是真正必要的,因为它会造成延迟并使脚本不优雅且可能不可读。

这是发送 Control 而不是 RButton 的代码,但这只是为了让我可以在 Notepad++ 中测试它。

只需将 Control 替换为 RButton 即可:

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

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