【问题标题】:How to suspend the autohotkey script for just one keystroke if the RSHIFT key is pressed如果按下 RSHIFT 键,如何暂停一次按键的自动热键脚本
【发布时间】:2017-04-25 22:52:55
【问题描述】:

我有以下自动热键脚本。我希望(1)当我按下并释放 RShift 时,脚本会暂停下一次击键(即,仅按一次按键)和(2)当我按住 RShift 时,脚本会暂停,直到我释放 RShift。 不幸的是,以下代码仅执行 (2) 而不是 (1)。我正在寻找一个正确的代码来执行 (1) 和 (2)。

AppsKey::RButton

RShift::Suspend, On
RShift Up::Suspend, Off

【问题讨论】:

    标签: autohotkey


    【解决方案1】:
    RShift::
    KeyWait, RShift, T0.3
    ; Release RShift in less than 0,3 seconds after pressing it 
    ; to suspend the script for the next keystroke
    If (!ErrorLevel)
    {
        Suspend On
        ; BlockInput On
        SetTimer OneKeyPressed, 200
    }
    else
    {
    ; Hold RShift pressed for more than 0,3 seconds 
    ; to suspend until you release RShift
        while GetKeyState("RShift", "P")
            Suspend On
        KeyWait, RShift, L
            Suspend, Off
    }
    return
    
    
    #If A_IsSuspended
    
        RShift Up:: Suspend, Off
    
    #If
    
    OneKeyPressed:
    If (A_TimeIdlePhysical < 100) 
    {
      SetTimer OneKeyPressed, off
      ; BlockInput Off
      Suspend Off  
    }
    return
    

    【讨论】:

    • 非常感谢,这似乎解决了问题。让我等一会儿,有机会得到其他答案。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-27
    • 2021-10-22
    • 2013-03-20
    • 2023-04-02
    相关资源
    最近更新 更多