从我上次按下箭头键开始计算时间

时间:2016-01-22 14:26:15

标签: input autohotkey

我之前在论坛上解释过如何使用输入命令编写autohotkey脚本以暂停脚本执行,直到输入字母数字字符为止:

 Input, L, V L1 T2       ;wait until you start typing a letter and then proceed after the T2 pause
 If (ErrorLevel =  "Timeout") {
 Send, {Tab 5}       
 Send, {Enter}       
 Return              
 }

我想知道我是否可以使用Input或其他一些autohotkey命令对非字母数字键执行相同操作,例如箭头键,甚至键组合。例如,我希望脚本在我从下拉列表中选择项目时按下上一次按下箭头键的时间,并且当预设时间阈值被传递以继续执行时剧本。

编辑:

感谢Blauhirn,脚本现在可以添加上下键:)(只要在此示例中在预设的两秒钟内输入第一个键,记事本将尽快启动作为打字的暂停一秒钟)

!^+u::

   Input, L, V L1 T2, {up} {down}    
    If (ErrorLevel =  "Timeout") {

         Send, {Esc}
        Return              
    }
    Loop {                  ;wait until you haven't typed an arrow key for 1seconds
        Input, L, V L1 T1, {up} {down}
        If (ErrorLevel =  "Timeout")
            Break
    }
        Run, %windir%\system32\notepad.exe
        Return              

1 个答案:

答案 0 :(得分:0)

如果您声明了一些 EndKeys ,则输入也将终止,ErrorLevel将为EndKey:name,因此 "Timeout"

 Input, L, V L1 T2, {up}{down}       ;wait until you start typing a letter -OR UP ARROW OR DOWN ARROW - and then proceed after the T2 pause
 If (ErrorLevel =  "Timeout") {
 Send, {Tab 5}       
 Send, {Enter}       
 Return              
 }