如果按下RSHIFT键,如何暂停一次击键的autohotkey脚本

时间:2016-12-10 16:30:23

标签: autohotkey

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

AppsKey::RButton

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

1 个答案:

答案 0 :(得分: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