I am relatively new to AutoHotKey, so please forgive me if this is common knowledge.
I recently found myself wanting to launch different directories based on a single or double keypress. The example provided at
http://www.autohotkey.com/docs/commands/KeyWait.htm was limiting. On detection of a double keypress, it would launch both the double and single keypress actions due to its logic.
So I have written my own script based on setTimer. The advantage is you're not limited to single/double keypresses - you can have triple/quadruple or quintuples.
Hope it proves useful:
Code:
; Keypress detection for Win C.
#c::
if counter >= 0 ; setTimer already started, so we log the keypress instead
{
counter++
return
}
counter = 0 ; Start setTimer and set the number of logged keypresses to 0
setTimer,keyWinC, 400
return
keyWinC:
setTimer,keyWinC,off
if counter = 0 ; The key is pressed once
{
Run, m:\
}
if counter = 1 ; The key is pressed twice
{
Run, m:\multimedia
}
if counter = 2 ; The key is pressed thrice
{
msgBox,Three clicks detected
}
counter = -1
return