2015-08-22 2 views
1

Я имею в виду, что если я нажимаю клавишу A, тогда он проверяет ключ B при нажатии второй клавиши, а затем, если это так, он проверяет ключ C. Если это не тот ключ, который он ждет, он возвращается к клавише A.AutoHotkey: проверить последовательность клавиш?

+1

использование [вход] (http://ahkscript.org/docs/commands/Input.htm) – Blauhirn

+0

звучит как пароль или или пароль .. – Leptonator

+0

также звучит как [hotstring] (http://ahkscript.org/docs/Hotstrings.htm) – blackholyman

ответ

1

Это может быть достигнуто путем присвоения ключа А как Hotkey, а затем команды Input оценить следующее нажатие клавиши. Промойте нажатой клавишу с помощью команды If, если это правда, тогда у вас есть другая команда ввода, чтобы оценить следующую нажатие клавиши и т. Д. И т. Д.

На странице «Вход» в Документах показан пример кода этого метода.

; 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 

Чтобы изменить вход, чтобы принимать только один ключ инсульта вам простые изменить параметр на команды ввода от L4 к L1 и положить все, что ключ вы хотите, как в кавычках, как список соответствия, например.

Пример не проверял, но должно быть близко к тому, что вы хотите:

~A:: 
Input, UserInput, V T5 L1, , "B" 

If (UserInput = "B") 
    Input, UserInput, V T5 L1, , "C" 
     If (UserInput = "C") 
      .... Some more code here... 
Смежные вопросы