0

I was explained before on the forum how to program an autohotkey script to pause the script execution until alpha-numerical character has been entered, by using an input command:

 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              
 }

I wonder if I can use Input or some other autohotkey command to do the same for non-alphanumerical keys, like arrow keys, or even key combinations. For example, I'd like for the script to count the time from my last arrow key press when I'm selecting an item from a drop-down list, and when the pre-set time threshold is passed to continue with the execution of the script.

EDIT:

Thanks to Blauhirn, the script works now the up and down keys are added :) (as long as the first key is typed in within the pre-set time period of two seconds in this example, notepad will be launched as soon as a pause of one second in typing is made)

!^+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              
  • not sure if this is possible withi `input`, but definitely with Hotkeys (or maybe even better, the `hotkey` command) – phil294 Jan 22 '16 at 14:30
  • Any idea how to do that Blauhirn? –  Jan 22 '16 at 14:34
  • 1
    Your question is fairly misleading. I will change it to what I consider it is really about. Give me your feedback when you can. – 2501 Jan 22 '16 at 15:06
  • Thank you for the help 2501, and I apologize if my question was unclear. I want the script to pause and wait for the input of an arrow command and wait as long as I keep pressing arrow keys (i.e selecting items in the drop-down list) within the pre-set interval and once I've made a pause of say, a second, or any other pre-set amount of time, to fire up the rest of the actions in the script (in your example, show a tooltip). Your script triggers the action of showing a tooltip automatically, while I'd want it to wait as long as the time threshold of pressing arrow keys is not passed. –  Jan 22 '16 at 15:47
  • If that helps here http://stackoverflow.com/questions/32358449/autohotkey-script-to-bookmark-to-a-specific-folder/32359494 Forivin provided a working script which does this - waits for the input of any alpha-numerical character and if the pause between the inputted characters is longer than 0.4 seconds it triggers the execution of the rest of the script. All I need is to make it work with arrow keys or key combinations instead of alphanumerical characters. –  Jan 22 '16 at 16:04
  • I described how you can easily modify the script to do whatever you want. Replacing the tooptip with a suspend command is the easing thing you can do. It seems like you are asking for a complete code solution. This service is not available on SO. I suggest you use the answer I posted and ask a new clear simple question. – 2501 Jan 22 '16 at 16:30
  • You're absolutely right 2501, I'm looking for a complete answer to my question, your code doesn't answer my question. I provided the link to the question I asked before on the forum with a code which does what I want only with alphanumerical characters and I'm looking for the same thing only with navigation arrows. I'm afraid I can't make my question clearer than that. –  Jan 22 '16 at 17:25
  • Please 2501 revert back the title of the thread to how I put my question, your question wasn't what I wanted to ask and I already told you that, you didn't understand my question. Again, I don't want to count the time from my last press, I want the script to wait for an input command and wait for a pre-set period of time before continuing the execution of the script. I referred you to another thread to get an idea what I was looking for, you misunderstood my question. Thank you for the consideration. –  Jan 22 '16 at 21:48

1 Answers1

-1

If you state some EndKeys, the input will also terminate and ErrorLevel will be EndKey:name, thus not "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              
 }
phil294
  • 10,038
  • 8
  • 65
  • 98
  • Thank you Blauhirn! The problem is that pressing an arrow key terminates the execution of the script, so I don't get the Tab and Enter commands executed once I pressed an arrow key. Good to know that adding up and down keys is possible, I'll try a loop command and see what I get. –  Jan 22 '16 at 21:58
  • @RejlanGivens I don't understand what you're saying. The script doesn't exit when pressing up/down. I copied the exact same post of yours and added ending keys. The only difference to your code snippet is: up/down makes `input` terminate with an error level *other* than "timeout" also. – phil294 Jan 22 '16 at 22:19
  • No Blauhirn, try with notepad and you'll see that pressing arrow keys or any key within the set period of two seconds will prevent launching the notepad using your script. You need a Loop command for the script to launch notepad once you stopped typing. That's all I know about this, Forivin will know why it is so :) –  Jan 22 '16 at 22:29