aboutsummaryrefslogtreecommitdiff
path: root/tt.doubleclick.ahk
diff options
context:
space:
mode:
Diffstat (limited to 'tt.doubleclick.ahk')
-rw-r--r--tt.doubleclick.ahk90
1 files changed, 45 insertions, 45 deletions
diff --git a/tt.doubleclick.ahk b/tt.doubleclick.ahk
index 0b2454b..58d83f4 100644
--- a/tt.doubleclick.ahk
+++ b/tt.doubleclick.ahk
@@ -15,14 +15,14 @@
DoubleClick(alternate := false)
{
-
+
;; A bunch of global variables are needed to determine whether a double click
;; has been performed:
-
- global DoubleClickClicked
- global DoubleClickPriorX
- global DoubleClickPriorY
- global DoubleClickLast
+
+ global DoubleClickClicked
+ global DoubleClickPriorX
+ global DoubleClickPriorY
+ global DoubleClickLast
;; The DoubleClickClicked variable should be set to false in the beginning of
;; the script: -> init
@@ -34,16 +34,16 @@ DoubleClickClicked := false
;; The maximum double click area (x * y) and time (in milliseconds) are
;; retrieved from Windows:
- SysGet, SM_CXDOUBLECLK, 36
- SysGet, SM_CYDOUBLECLK, 37
- max := DllCall("User32\GetDoubleClickTime")
+ SysGet, SM_CXDOUBLECLK, 36
+ SysGet, SM_CYDOUBLECLK, 37
+ max := DllCall("User32\GetDoubleClickTime")
;; The current absolute position of the mouse is retrieved:
-
- tmp := A_CoordModeMouse
- CoordMode, Mouse, Screen
- MouseGetPos, x, y
- CoordMode, Mouse, %tmp%
+
+ tmp := A_CoordModeMouse
+ CoordMode, Mouse, Screen
+ MouseGetPos, x, y
+ CoordMode, Mouse, %tmp%
;; The DoubleClickClicked variable, if true, signifies that a first click has
;; already been performed. If false, a double click has not been initiated.
@@ -52,43 +52,43 @@ DoubleClickClicked := false
;; The first click should be allowed to pass through, but the function takes
;; note of the click and sets the global variables against which to compare
;; the next click:
-
- if (not DoubleClickClicked)
- {
- if (alternate)
- SendInput, {Click, right}
- else
- SendInput, {Click}
- DoubleClickPriorX := x
- DoubleClickPriorY := y
- DoubleClickLast := A_TickCount
- DoubleClickClicked := true
- return false
- }
+
+ if (not DoubleClickClicked)
+ {
+ if (alternate)
+ SendInput, {Click, right}
+ else
+ SendInput, {Click}
+ DoubleClickPriorX := x
+ DoubleClickPriorY := y
+ DoubleClickLast := A_TickCount
+ DoubleClickClicked := true
+ return false
+ }
;; At this point, the function has been called for the second time, signifying
;; a second click. Now, it checks whether the two clicks meet the operating
;; system's requirements for a double click; if not, then this click is treated
;; as yet another first click:
-
- if (A_TickCount - DoubleClickLast > max
- || abs(x - DoubleClickPriorX) > SM_CXDOUBLECLK
- || abs(y - DoubleClickPriorY) > SM_CYDOUBLECLK)
- {
- if (alternate)
- SendInput, {Click, right}
- else
- SendInput, {Click}
- DoubleClickPriorX := x
- DoubleClickPriorY := y
- DoubleClickLast := A_TickCount
- DoubleClickClicked := true
- return false
- }
+
+ if (A_TickCount - DoubleClickLast > max
+ || abs(x - DoubleClickPriorX) > SM_CXDOUBLECLK
+ || abs(y - DoubleClickPriorY) > SM_CYDOUBLECLK)
+ {
+ if (alternate)
+ SendInput, {Click, right}
+ else
+ SendInput, {Click}
+ DoubleClickPriorX := x
+ DoubleClickPriorY := y
+ DoubleClickLast := A_TickCount
+ DoubleClickClicked := true
+ return false
+ }
;; At this point, a double click has successfully been performed. The variable
;; signifying a first click is reset to false, and the function returns true:
-
- DoubleClickClicked := false
- return true
+
+ DoubleClickClicked := false
+ return true
}