
Entering commands using double-tapped Shift
Please let me know if this is possible to do (and, if so, how to do it):
I’d like to be able to “double–tap” the left Shift key to bring up an input window, enter a command into that window, then press Shift again to execute the command. The idea is to be able to enter commands entirely with the left Shift key and the keys on the left side of a split keyboard.
Much obliged,
— Rat

There are a few tricks:
- You can define LShift as a hotkey. It has to check if it was activated within 300 ms again, as a possible indication of a double tap.
- If you want to catch further LShifts (for sending commands), you have to exit the hotkey routine, but still do some work. It is done by starting a timer, which calls the Inp function every 10 ms. Inp stops this timer immediately after activation, so it is executed only once, but not within the LShift hotkey routine.
- If LShift was pressed and the active window is the InputBox, which has been started in the Inp routine, we can Send {Enter}, so LShift activates the command. Esc will close it, as mouse clicks.
~Lshift:: If (A_ThisHotkey = A_PriorHotkey and A_TimeSincePriorHotkey < 300) SetTimer Inp, 10 Else IfWinActive ahk_class #32770 Send {Enter} Return Inp: SetTimer Inp, Off InputBox cmd, Cmd Input, Type your command,, 200, 140 Run %cmd% Return

Please search the forum. There was a topic by ezuk with the same request to execute commands only with rapid CTRL key presses.
PS: I'll remove your duplicate post.

toralf
I use the latest AHK version (1.1.15+)
Please ask questions in forum on ahkscript.org. Why?
For online reference please use these Docs.

I noticed the Start>Run window and Internet Explorer's Open window are also ahk_class #32770. Here's a modification of your script.
~Lshift:: If (A_ThisHotkey = A_PriorHotkey and A_TimeSincePriorHotkey < 300) SetTimer Inp, 10 Else If (WinActive("ahk_class #32770") and WinActive("Cmd Input")) Send {Enter} Return Inp: SetTimer Inp, Off InputBox cmd, Cmd Input, Type your command,, 200, 140 Run %cmd% Return

Yes, I agree it is an extra challenge. But I'm sure your script atBut here we had the extra challenge that inside a hotkey routine the same hotkey has to be triggered again. This timer trick is not easy to figure out or find in the help (I have seen it, but forgot where).
http://www.autohotke...opic.php?t=4640
would have been a good starting point as well, since it is easy to extend. :) That's why I mentioned it.
As for the manual, under Threads it says:
Related to the above: A single script can have multiple simultaneous MsgBox, InputBox, FileSelectFile, and FileSelectFolder dialogs. This is achieved by launching a new thread (via hotkey, timed subroutine, or custom menu item) while a prior thread already has a dialog displayed.
By default, a given hotkey or hotstring subroutine cannot be run a second time if it is already running. Use #MaxThreadsPerHotkey to change this behavior.

toralf
I use the latest AHK version (1.1.15+)
Please ask questions in forum on ahkscript.org. Why?
For online reference please use these Docs.
#MaxThreadsPerHotkey 2 ~Lshift:: If (A_ThisHotkey = A_PriorHotkey and A_TimeSincePriorHotkey < 300) { InputBox cmd, Cmd Input, Type your command,, 200, 140 Run %cmd% } Else If (WinActive("ahk_class #32770") and WinActive("Cmd Input")) Send {Enter} ReturnThis version is a bit sensitive, though, as the auto-repeat function of the keyboard fires the hotkey twice, if you keep the Shift key pressed down long enough. If you have 2 InputBox-es open, the Shift key does not close any of them, as no more threads can be started. With more threads per hotkey, you could easily end up with several InputBox-es open. The original version does not open more than one InputBox at a time, so it looks more robust.

Since that worked out so well I wonder if you could tell me whether it’s possible to have a command enter as soon as I enter two keys. As an example, here’s what I’m doing currently (based on the script Laszlo provided):
#MaxThreadsPerHotkey 2 ~LCtrl:: If (A_ThisHotkey = A_PriorHotkey and A_TimeSincePriorHotkey < 300) { InputBox, strUserInput, Command, Please enter a command. IfEqual, strUserInput, ds, Run, https://signin.dell.com/premier/portal/login.aspx IfEqual, strUserInput, qq, Run, http://www.mapquest.com/ IfEqual, strUserInput, ex, Run, C:\Program Files\Outlook Express\msimn.exe } Else If (WinActive("ahk_class #32770") and WinActive("Command")) Send {Enter} ReturnThere are a number of other two–letter commands — this just lists a few examples. What I’d like to happen is to have the code execute as soon as I type, say, “ds” or “qq” without hitting Left Control again. So it’d go from Ctrl, Ctrl, d,s, Ctrl {execute} to Ctrl, Ctrl, d, s {execute}
Is that doable or is it getting too complicated?
Ultimately I’d like to get this to work without using an input box at all but that isn’t hugely important.
Thanks for your help!
— Rat

You are looking for hotstrings in the above case.
Regarding the last wish: Why do you ask us to help you to do this, when you want to do another thing? You can just use hotkeys to run things. You do not have to use the input box, just the command "run" that is started called by a hotkey.
I highly recommend you to read the manual.

toralf
I use the latest AHK version (1.1.15+)
Please ask questions in forum on ahkscript.org. Why?
For online reference please use these Docs.
~$LCtrl:: If (A_ThisHotkey = A_PriorHotkey and A_TimeSincePriorHotkey < 300) { TrayTip,,Type your Command: Input k1, L1, {ESC}{Space} ; ESC, Space cancels IfEqual k1,, { TrayTip Return } TrayTip,,Type your Command: %k1% Input k2, L1, {ESC}{Space} ; other not visible keys ignored IfEqual k2,, { TrayTip Return } TrayTip,,Type your Command: %k1%%k2% k = %k1%%k2% IfEqual k, aa, MsgBox AA IfEqual k, az, MsgBox AZ IfEqual k, zz, MsgBox ZZ TrayTip } Return

Aha! Once again I am amazed by the versatility of this program and the helpfulness of the users on this forum. Thanks much for your assistance Laszlo — those are some pretty cool tricks.Now the task is: double tapping on the left Control key activates a hotstring-like functionality, but without the foreground application receiving the keystrokes.
I acknowledge that I could probably discover how to do these things with a lot of trial and error but it helps a lot to have examples I can use as a springboard.
Thanks again,
— Rat

I understand the wish for a springboard. And we are most happy to provide one. But at the end it is best to ask the right questions in the beginning.
From what I read in your last post. This should do the same thing:
^s:: If GetKeyState("d") Run, https://signin.dell.com/premier/portal/login.aspx return ^q:: If GetKeyState("q") Run, http://www.mapquest.com/ return ^x:: If GetKeyState("e") Run, C:\Program Files\Outlook Express\msimn.exe returnPlease press
Ctrl+d plus s
Ctrl+q plus q
Ctrl+e plus x
to execute.

