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 

A double click hotkey
Goto page 1, 2  Next
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
spunch
Guest





PostPosted: Wed Sep 20, 2006 3:15 pm    Post subject: A double click hotkey Reply with quote

Is it possible to create a hotkey that will do something once a (special) key is double clicked?

For example, I want something to run once I press ctrl twice in a short period of time, but still have ctrl behave normally when I don't double click (sort of like how the quick search box in google desktop works, if anybody uses it).

I know it's possible using hotstrings and regular characters, it would look something like this:
:*:aa::Run, %something%

But can I use special keys such as ctrl/alt/shift/capslock for that?
Back to top
PhiLho



Joined: 27 Dec 2005
Posts: 6721
Location: France (near Paris)

PostPosted: Wed Sep 20, 2006 4:55 pm    Post subject: Reply with quote

That's not exactly a double-click but a double-press...
Code:
Ctrl::
   If (A_PriorHotKey = A_ThisHotKey and A_TimeSincePriorHotkey < 500)
      MsgBox You double-pressed Ctrl!
Return
For some reason, when active, it triggers when I use hotkeys like:
:*c:ēc::[ code][/code]{Left 7}
I don't see why...

[EDIT] I recall a related topic: AHK Randomly Presses and Unpresses Alt and Ctrl which answers (partly) the question: on my keyboard, I have to use AltGr+( to get [, and AHK sends Ctrl to cancel this Alt. Note that this isn't necessary with Right Alt (aka. AltGr) because it doesn't trigger menues. At least on my French system.
_________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")


Last edited by PhiLho on Mon Nov 13, 2006 3:03 pm; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
Hacker



Joined: 10 Jun 2006
Posts: 65
Location: Bratislava, Slovakia

PostPosted: Fri Nov 10, 2006 9:09 pm    Post subject: Reply with quote

Does someone please know how to find out the current double-click delay set in windows?

TIA
Roman
Back to top
View user's profile Send private message
Titan



Joined: 11 Aug 2004
Posts: 5068
Location: imaginationland

PostPosted: Fri Nov 10, 2006 9:43 pm    Post subject: Reply with quote

Hacker wrote:
Does someone please know how to find out the current double-click delay set in windows?
DllCall("GetDoubleClickTime")
_________________

RegExReplace("irc.freenode.net/ahk", "^(?=(.(?=[\0-r\[]*((?<=\.).))))(?:[c-\x73]{2,8}(\S))+((2)|\b[^\2-]){2}\D++$", "$u3$1$3$4$2")
Back to top
View user's profile Send private message Visit poster's website
Hacker



Joined: 10 Jun 2006
Posts: 65
Location: Bratislava, Slovakia

PostPosted: Sat Nov 11, 2006 12:50 am    Post subject: Reply with quote

Thank you! Smile

Roman
Back to top
View user's profile Send private message
wallywalters



Joined: 27 Sep 2006
Posts: 16

PostPosted: Sat Nov 11, 2006 3:52 am    Post subject: Reply with quote

I don't believe it. I just logged in intending to post this very question.

You guys are the greatest!
Back to top
View user's profile Send private message
quicktest



Joined: 30 Jul 2004
Posts: 42

PostPosted: Sat Nov 11, 2006 5:32 am    Post subject: Reply with quote

And I posted this question just 5 days ago, but worded it very poorly and got no response at all Embarassed

Thanks spunch and PhilLo Smile
Back to top
View user's profile Send private message
wallywalters



Joined: 27 Sep 2006
Posts: 16

PostPosted: Sat Nov 11, 2006 8:21 am    Post subject: Reply with quote

Just curious: What's the advantage to handling this using A_PriorHotkey vs. KeyWait, as below?

; Method #2
; ---------
F10::
KeyWait, F10
KeyWait, F10, D, T0.10
If ErrorLevel = 1
MsgBox Single Keypress
Else
MsgBox Double Keypress
Return
Back to top
View user's profile Send private message
PhiLho



Joined: 27 Dec 2005
Posts: 6721
Location: France (near Paris)

PostPosted: Sat Nov 11, 2006 10:59 am    Post subject: Reply with quote

Probably no real advantage, there are often several ways to reach a goal in programming world...
Thanks for proposing an alternative solution.
_________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")
Back to top
View user's profile Send private message Visit poster's website
Hacker



Joined: 10 Jun 2006
Posts: 65
Location: Bratislava, Slovakia

PostPosted: Sat Nov 11, 2006 8:17 pm    Post subject: Reply with quote

Hm, now I am trying to get the time since the last hotkey like this:
Code:
$~LButton::
   TimeBetweenClicks = %A_TimeSincePriorHotkey%
   EnvSub, TimeBetweenClicks, %A_TimeSinceThisHotkey%
   ToolTip, %TimeBetweenClicks%
Return

But after any one doubleclick the value never is lower than cca. 340. How come?

It seems to show the correct value if I tripleclick, however...(??)

TIA
Roman
P.S.: I subtract A_TimeSinceThisHotkey because this is part of a larger script that handles this hotkey and the evaluation is not done at the beginning. In case anyone wonders.
Back to top
View user's profile Send private message
xXJa50nXx



Joined: 19 Oct 2006
Posts: 32
Location: mo

PostPosted: Sat Nov 11, 2006 10:16 pm    Post subject: Reply with quote

There is a built in variable for that
use %A_TimeSincePriorHotkey%.
Back to top
View user's profile Send private message Send e-mail
Hacker



Joined: 10 Jun 2006
Posts: 65
Location: Bratislava, Slovakia

PostPosted: Mon Nov 13, 2006 2:46 pm    Post subject: Reply with quote

xXJa50nXx,
As you can see, I am already using it, but am trying to enhance its precision, which does not seem to work.

Roman
Back to top
View user's profile Send private message
Hacker



Joined: 10 Jun 2006
Posts: 65
Location: Bratislava, Slovakia

PostPosted: Tue Nov 14, 2006 1:06 pm    Post subject: Reply with quote

Anyone, please?

TIA
Roman
Back to top
View user's profile Send private message
Hacker



Joined: 10 Jun 2006
Posts: 65
Location: Bratislava, Slovakia

PostPosted: Sat Nov 18, 2006 11:37 am    Post subject: Reply with quote

Well, this code definitely does not work as expected. A_TimeSincePriorHotkey returns higher values than it should. It also seems that it returns correct values if I move the cursor a little between the two clicks of the double-click, just between the confines of the XDblClickDiff and YDblClickDiff rectangle.

Code:
#SingleInstance, Force

SysGet, XDblClickDiff, 36
SysGet, YDblClickDiff, 37
SystemDoubleClickTime := DllCall("GetDoubleClickTime")

~LButton::
   MouseGetPos, X, Y
   IfEqual, A_ThisHotkey, %A_PriorHotkey%
      IfLess, A_TimeSincePriorHotkey, %SystemDoubleClickTime%
      {
         EnvSub, PriorX, %X%
         Transform, PriorX, Abs, %PriorX%
         IfLessOrEqual, PriorX, %XDblClickDiff%
         {
            EnvSub, PriorY, %Y%
            Transform, PriorY, Abs, %PriorY%
            IfLessOrEqual, PriorY, %YDblClickDiff%
               SoundBeep
         }
      }
   PriorX = %X%
   PriorY = %Y%
Return


TIA
Roman
Back to top
View user's profile Send private message
Hacker



Joined: 10 Jun 2006
Posts: 65
Location: Bratislava, Slovakia

PostPosted: Mon Nov 20, 2006 8:06 pm    Post subject: Reply with quote

Pretty please...?

Roman
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
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