-
Notifications
You must be signed in to change notification settings - Fork 0
/
shade.ahk
92 lines (76 loc) · 1.52 KB
/
shade.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#NoEnv
#SingleInstance, Force
#MaxHotkeysPerInterval 100
SetKeyDelay, 0
tb_siz := 30
dblclk_t := 200
IDs := []
OnExit("cleanup")
$WheelDown::
$WheelUp::
$LButton::
$MButton::
hk := A_ThisHotKey
hkn := LTrim(hk, "$")
whl := InStr(hkn, "Wheel")
CoordMode, Mouse, Screen
MouseGetPos, mX, mY, winID
WinGetPos, wX, wY,,, ahk_id %winID%
dbl := (A_PriorHotkey==hk && A_TimeSincePriorHotkey<dblclk_t)
if(mY-wY>tb_siz || (hkn=="LButton" && !dbl)) {
if(whl) {
Send {%hkn%}
} else {
btn := SubStr(hkn, 1, 1)
MouseClick, % btn,,,,, D
KeyWait, % hkn
MouseClick, % btn,,,,, U
}
return
}
rollup(whl?hkn!="WheelUp":2)
return
$^MButton::
MouseGetPos,,, winID
rollup()
return
; t==0 roll up, t==1 roll down, t==2 toggle
rollup(type := 2) {
global IDs, winID
if(type) {
for i, e in IDs {
if(InStr(e, winID)) {
t := StrSplit(e, "|")
WinActivate, % "ahk_id" t[1]
WinMove, % "ahk_id" t[1],,,,, % t[2]
IDs.Delete(i)
return
}
}
}
if(type!=1) {
for i, e in IDs {
if(InStr(e, winID)) {
return
}
}
WinGet, pN, ProcessName, ahk_id %winID%
if(InStr(pN, "Thunderbird")) {
nh := 38
} else {
nh := 30
}
WinGetPos,,,, winH, ahk_id %winID%
WinMove, ahk_id %winID%,,,,, %nh%
t = %winID%|%winH%
IDs.Push(t)
}
}
cleanup() {
global IDs
for i, e in IDs {
t := StrSplit(e, "|")
WinMove, % "ahk_id" t[1],,,,, % t[2]
}
return 0
}