AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Single/double/triple keypress hotkey

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
Scrawl
Guest





PostPosted: Fri Nov 05, 2004 10:15 am    Post subject: Single/double/triple keypress hotkey Reply with quote

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

PostPosted: Fri Nov 05, 2004 11:48 am    Post subject: Reply with quote

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. Cool
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
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group