AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Input command interrupted by hotkeys

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Wish List
View previous topic :: View next topic  
Author Message
arbe



Joined: 12 Apr 2005
Posts: 30

PostPosted: Wed May 10, 2006 6:53 pm    Post subject: Input command interrupted by hotkeys Reply with quote

The Input command is currently interruptable by hotkeys:

Quote:
While an Input is in progress, new threads such as custom menu items and timed subroutines can still be created. Similarly, keyboard hotkeys are still in effect if the Input is visible. If the Input is not visible, only hook hotkeys can be triggered.


Still, in an example provided in the help, Chris sees the benefit of having a way to wait for the next user input by providing this code snippet:

Quote:
; Wait for the user to press any key. Keys that produce no visible character,
; such as the modifier keys, function keys, and arrow keys, are listed as end keys
; so that they will be detected too.
Input, SingleKey, L1, {LControl}{RControl}{LAlt}{RAlt}{LShift}{RShift}{LWin}{RWin}{F1}{F2}{F3}{F4}{F5}{F6}{F7}{F8}{F9}{F10}{F11}{F12}
{Left}{Right}{Up}{Down}{Home}{End}{PgUp}{PgDn}{Del}{Ins}{BS}{Capslock}{Numlock}{PrintScreen}{Pause}


Unfortunately, it does not work in the intended way when there are hotkeys activated. Chris, would you be able to add another parameter that interrupts the input command no matter if a hotkey was pressed?

The syntax could be:
Input [, OutputVar, Options, EndKeys, MatchList, HotkeysInterrupt]
with HotkeysInterrupt being a binary variable.

This option would be very helpful to let the user indicate when certain tasks in the target application finish. For example, once in a while I have a problem with this use case:
Code:
#v:
  backup:=clipboard
  clipboard=test
  send ^v
  sleep 500
  clipboard:=backup
return

Sometimes, the target application is too slow to fetch the clipboard contents before they are restored after half a second. Extending the sleep interval is not a good idea since the user does not want to wait for the original clipboard contents for too long.

(The above is a simple example. Using the send command instead of clipboard pasting is not sufficient in some use cases.)

The suggested modification to the input command would allow an AHK programmer to let the user indicate that the target application has processed the ^v pasting. If he triggers #v he will typically not press any further keys until the last command (pasting "test") has finished. When he does press the next key, the original clipboard content should be restored since the next key sequence might be a regular ^v or another hotkey that uses the clipboard.
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10480

PostPosted: Wed May 10, 2006 8:20 pm    Post subject: Reply with quote

As it stands now, the benefits don't seem substantial enough or (I don't understand them well enough) to commit adding such a feature. However, there is already a plan to add an OnKeystroke feature that would allow the script to receive all key presses so that it can decide what the user really intends. When implemented, perhaps it will be suitable for this task too.

Until then, maybe there is some other way to achieve the goal.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Wish List All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group