Autohotkey 如何制作;“块输入开/关”;仅阻止键盘输入,不阻止鼠标输入

Autohotkey 如何制作;“块输入开/关”;仅阻止键盘输入,不阻止鼠标输入,autohotkey,Autohotkey,正如标题所说,我很难找到一种方法让我的脚本在脚本期间只阻止键盘输入。有没有一种方法是我忽略的?以下是我的代码供参考: 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 dow

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

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
}