2009-11-25 8 views
22

キーをダブルクリックすると、AutoHotkeyでイベントをトリガーしたいと思います。しかし、二重プレスではない場合には、エスケープキーストロークをフォーカスに合わせてアプリケーションに移動させるようにします(1秒以内に)。AutoHotkeyでダブルキーを検出する

どうすればいいですか?

は、私がこれまでに作ってみたが、私は、第二のエスケープキーを押すかどうかを確認する方法を考え出すことはできません。

~Esc:: 

    Input, TextEntry1, L1 T1 
    endKey=%ErrorLevel% 

    if(endKey != "Timeout") 
    { 
     ; perform my double press operation 
     WinMinimize, A 
    } 
return 

答えて

29

AutoHotkey documentationで答えを見つけました!

; Example #4: Detects when a key has been double-pressed (similar to double-click). 
; KeyWait is used to stop the keyboard's auto-repeat feature from creating an unwanted 
; double-press when you hold down the RControl key to modify another key. It does this by 
; keeping the hotkey's thread running, which blocks the auto-repeats by relying upon 
; #MaxThreadsPerHotkey being at its default setting of 1. 
; Note: There is a more elaborate script to distinguish between single, double, and 
; triple-presses at the bottom of the SetTimer page. 

~RControl:: 
if (A_PriorHotkey <> "~RControl" or A_TimeSincePriorHotkey > 400) 
{ 
    ; Too much time between presses, so this isn't a double-press. 
    KeyWait, RControl 
    return 
} 
MsgBox You double-pressed the right control key. 
return 

だから私の場合のために:上記のスクリプトでは

~Esc:: 
if (A_PriorHotkey <> "~Esc" or A_TimeSincePriorHotkey > 400) 
{ 
    ; Too much time between presses, so this isn't a double-press. 
    KeyWait, Esc 
    return 
} 
WinMinimize, A 
return 
+6

(私は二重の「D」キーを押しを検出したかった)私のためにトリックを行うようです! –

+1

ダブルクリックの処理を探している人のために(私のように)。この答えは '〜LButton 'と同様に働きます。 –

1

、私は私が検出したかったボタンは、プログラム(すなわち「〜」接頭辞)にforwaredされていたことが判明しました。

これは、AutoHotkeyをでは、Windows CHMは、これまでのファイルを助け最高の1つを有し

d:: 
keywait,d 
keywait,d,d t0.5 ; Increase the "t" value for a longer timeout. 
if errorlevel 
{ 
    ; pretend that nothing happened and forward the single "d" 
    Send d 
    return 
} 
; A double "d" has been detected, act accordingly. 
Send {Del} 
return 

Source