-
Notifications
You must be signed in to change notification settings - Fork 72
/
Copy pathMouseExtras.ahk
78 lines (73 loc) · 1.78 KB
/
MouseExtras.ahk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
; MouseExtras
; Author: Pulover [Rodolfo U. Batista]
/*
- Allows to use subroutines for Holding and Double Clicking a Mouse Button.
- Keeps One-Click and Drag functions.
- Works with combinations, i.e. LButton & RButton.
Usage:
Assign the function to the Mouse Hotkey and input the Labels to
trigger with GoSub and wait times in the parameters:
MouseExtras("HoldSub", "DoubleSub", "HoldTime", "DClickTime", "Button")
HoldSub: Button Hold Label.
HoldTime: Wait Time to Hold Button (miliseconds - optional).
DoubleSub: Double Click Label.
DClickTime: Wait Time for Double Click (seconds - optional).
Button: Choose a different Button (optional - may be useful for combinations).
- If you don't want to use a certain function put "" in the label.
- I recommend using the "*" prefix to allow them to work with modifiers.
- Note: Althought it's designed for MouseButtons it will work with Keyboard as well.
*/
MouseExtras(HoldSub, HoldTime="200", DoubleSub="", DClickTime="0.2", Button="")
{
If Button =
Button := A_ThisHotkey
Button := LTrim(Button, "~*$")
If InStr(Button, "&")
Button := RegExReplace(Button, "^.*&( +)?")
MouseGetPos, xpos
Loop
{
MouseGetPos, xposn
If (A_TimeSinceThisHotkey > HoldTime)
{
If IsLabel(HoldSub)
GoSub, %HoldSub%
Else
{
Send {%Button% Down}
KeyWait, %Button%
Send {%Button% Up}
}
return
}
Else
If (xpos <> xposn)
{
Send {%Button% Down}
KeyWait, %Button%
Send {%Button% Up}
return
}
Else
If !GetKeyState(Button, "P")
{
If !IsLabel(DoubleSub)
{
Send {%Button%}
return
}
KeyWait, %Button%, D T%DClickTime%
If ErrorLevel
Send {%Button%}
Else
{
If IsLabel(DoubleSub)
GoSub, %DoubleSub%
Else
Send {%Button%}
}
return
}
}
}