如何使 "BlockInput On/Off" 只阻止键盘输入而不是鼠标

How to make "BlockInput On/Off" only block keyboard inputs not mouse

正如标题所说,我很难找到一种方法让我的脚本在我的脚本执行期间只阻止键盘输入。有没有我忽略的方法来做到这一点?这是我的参考代码:

toggle = 0
*xbutton1::
{
  if GetKeyState("d", "P")
  {
    if GetKeyState("w", "P")
    {
        BlockInput On ;enabled
    Send, {d up}
    Send, {w up}
    Send, {a down}
    Send, {s down}
    Send, {K}
        BlockInput Off ;disabled when completed with the above actions ^ so no key inputs interfere
    Sleep, -1
    Send, {a up}
    Send, {s up}
    Send, {d down}
    Send, {w down}
    return
  }

谢谢!如果有任何信息或提示,我将不胜感激。

您可以创建一个函数来仅阻止键盘输入:

; Press F1 to block keyboard input for 10 seconds:

$F1::
    BlockKeyboard("On")
    Sleep, 10000
    BlockKeyboard("Off")
return

BlockKeyboard(state){
    Loop, 512
    {
        Key := Format("SC{:X}",A_Index)
        If (state = "On")
            Hotkey, *%Key%, KeyboardKey, On UseErrorLevel
        else
            Hotkey, *%Key%, KeyboardKey, Off UseErrorLevel
    }
    KeyboardKey:
    return
}