Reputation: 966
What I mean is that if I press the A key, it then tests for the B key on the second key press, then if it is, it tests for the C key. If any are not the key it's waiting for, it goes back to the A key.
Upvotes: 1
Views: 747
Reputation: 2672
This can be achieved by Assigning Key A as a Hotkey and then having a Input command evaluate the next key press. Evaulate the key pressed using If command, If true, then have another Input command evaluate the next key press etc etc ...
There appears to be Example code of this method on the Input page in the Docs.
; This is a working hotkey example. Since the hotkey has the tilde (~)
; prefix, its own keystroke will pass through to the active window.
; Thus, if you type [btw (or one of the other match
; phrases) in any editor, the script will automatically perform an
; action of your choice (such as replacing the typed text):
~[::
Input, UserInput, V T5 L4 C, {enter}.{esc}{tab}, btw,otoh,fl,ahk,ca
if (ErrorLevel = "Max")
{
MsgBox, You entered "%UserInput%", which is the maximum length of text.
return
}
if (ErrorLevel = "Timeout")
{
MsgBox, You entered "%UserInput%" at which time the input timed out.
return
}
if (ErrorLevel = "NewInput")
return
If InStr(ErrorLevel, "EndKey:")
{
MsgBox, You entered "%UserInput%" and terminated the input with %ErrorLevel%.
return
}
; Otherwise, a match was found.
if (UserInput = "btw")
Send, {backspace 4}by the way
else if (UserInput = "otoh")
Send, {backspace 5}on the other hand
else if (UserInput = "fl")
Send, {backspace 3}Florida
else if (UserInput = "ca")
Send, {backspace 3}California
else if (UserInput = "ahk")
Run, http://ahkscript.org
return
To modify the Input to only accept 1 key stroke you simple change the Option on the Input command from L4 to L1 and put whatever key you want as in Quotes as a match list, for example.
Example Not Tested but should be close to what you want:
~A::
Input, UserInput, V T5 L1, , "B"
If (UserInput = "B")
Input, UserInput, V T5 L1, , "C"
If (UserInput = "C")
.... Some more code here...
Upvotes: 1