 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Scrawl Guest
|
Posted: Fri Nov 05, 2004 10:15 am Post subject: Single/double/triple keypress hotkey |
|
|
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 |
|
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10467
|
Posted: Fri Nov 05, 2004 11:48 am Post subject: |
|
|
That's a great use of SetTimer. Since I think many others will find your example useful, I will include something similar in the help file for SetTimer.
| BoBo wrote: | Edited for better visability. Thx for sharing it.  | You beat me by a few minutes: the tabs were already in the post so I just applied the "code" style to it and removed your post. |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|