【问题标题】:How to make "BlockInput On/Off" only block keyboard inputs not mouse如何使“BlockInput On/Off”仅阻止键盘输入而不是鼠标
【发布时间】:2020-05-09 01:20:58
【问题描述】:

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

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
  }

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

【问题讨论】:

    标签: autohotkey


    【解决方案1】:

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

    ; 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
    }
    

    【讨论】:

      猜你喜欢
      • 2012-02-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-09-18
      • 2011-12-09
      • 1970-01-01
      • 2014-08-23
      相关资源
      最近更新 更多