AutoHotKeyで、キー二連打にいろいろ割り当ててみた。2
二連打は組み込み変数使えばもっとスマートにできるね。
PutEsc:
Send,{Esc}
return
$Esc::
WinGet, AWinHwnd, ID, A
if (BefAWinHwnd == AWinHwnd) && (A_PriorHotkey == A_ThisHotkey) && (200 > A_TimeSincePriorHotkey) {
SetTimer, PutEsc, OFF
send, !{F4}
} else {
BefAWinHwnd := AWinHwnd
SetTimer, PutEsc, -200
}
keywait, Esc
return
以前書いたAHKスクリプトを改良。前回、少しあとで簡単にできることに気づいたんだけど、それほど切迫してないしと放置してるあいだにそのことを忘れるというありがちな罠。
; Esc二連打でウィンドウ閉じる(1回だけならEsc)
PutEsc:
Send,{Esc}
return
$Esc::
if A_TickCount < %EscDouble%
{
SetTimer, PutEsc, OFF
EscDouble = 0
send, !{F4}
return
}
else
{
EscDouble = %A_TickCount%
EscDouble += 400
SetTimer, PutEsc, -400
}
KeyWait, Esc
return
説明するまでもない。便利。他に応用すれば便利そうな予感はするが、特にこれといって思いつかない(ぐへー。