AutoHotkey Community

It is currently May 27th, 2012, 9:02 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: November 5th, 2004, 10:15 am 
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


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 5th, 2004, 11:48 am 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
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. 8)
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.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 9 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group