| View previous topic :: View next topic |
| Author |
Message |
spunch Guest
|
Posted: Wed Sep 20, 2006 3:15 pm Post subject: A double click hotkey |
|
|
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)
|
Posted: Wed Sep 20, 2006 4:55 pm Post subject: |
|
|
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 |
|
 |
Hacker
Joined: 10 Jun 2006 Posts: 65 Location: Bratislava, Slovakia
|
Posted: Fri Nov 10, 2006 9:09 pm Post subject: |
|
|
Does someone please know how to find out the current double-click delay set in windows?
TIA
Roman |
|
| Back to top |
|
 |
Titan
Joined: 11 Aug 2004 Posts: 5068 Location: imaginationland
|
Posted: Fri Nov 10, 2006 9:43 pm Post subject: |
|
|
| 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 |
|
 |
Hacker
Joined: 10 Jun 2006 Posts: 65 Location: Bratislava, Slovakia
|
Posted: Sat Nov 11, 2006 12:50 am Post subject: |
|
|
Thank you!
Roman |
|
| Back to top |
|
 |
wallywalters
Joined: 27 Sep 2006 Posts: 16
|
Posted: Sat Nov 11, 2006 3:52 am Post subject: |
|
|
I don't believe it. I just logged in intending to post this very question.
You guys are the greatest! |
|
| Back to top |
|
 |
quicktest
Joined: 30 Jul 2004 Posts: 42
|
Posted: Sat Nov 11, 2006 5:32 am Post subject: |
|
|
And I posted this question just 5 days ago, but worded it very poorly and got no response at all
Thanks spunch and PhilLo  |
|
| Back to top |
|
 |
wallywalters
Joined: 27 Sep 2006 Posts: 16
|
Posted: Sat Nov 11, 2006 8:21 am Post subject: |
|
|
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 |
|
 |
PhiLho
Joined: 27 Dec 2005 Posts: 6721 Location: France (near Paris)
|
Posted: Sat Nov 11, 2006 10:59 am Post subject: |
|
|
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 |
|
 |
Hacker
Joined: 10 Jun 2006 Posts: 65 Location: Bratislava, Slovakia
|
Posted: Sat Nov 11, 2006 8:17 pm Post subject: |
|
|
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 |
|
 |
xXJa50nXx
Joined: 19 Oct 2006 Posts: 32 Location: mo
|
Posted: Sat Nov 11, 2006 10:16 pm Post subject: |
|
|
There is a built in variable for that
use %A_TimeSincePriorHotkey%. |
|
| Back to top |
|
 |
Hacker
Joined: 10 Jun 2006 Posts: 65 Location: Bratislava, Slovakia
|
Posted: Mon Nov 13, 2006 2:46 pm Post subject: |
|
|
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 |
|
 |
Hacker
Joined: 10 Jun 2006 Posts: 65 Location: Bratislava, Slovakia
|
Posted: Tue Nov 14, 2006 1:06 pm Post subject: |
|
|
Anyone, please?
TIA
Roman |
|
| Back to top |
|
 |
Hacker
Joined: 10 Jun 2006 Posts: 65 Location: Bratislava, Slovakia
|
Posted: Sat Nov 18, 2006 11:37 am Post subject: |
|
|
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 |
|
 |
Hacker
Joined: 10 Jun 2006 Posts: 65 Location: Bratislava, Slovakia
|
Posted: Mon Nov 20, 2006 8:06 pm Post subject: |
|
|
Pretty please...?
Roman |
|
| Back to top |
|
 |
|