forked from 7plus/7plus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TaskBar.ahk
168 lines (160 loc) · 4.27 KB
/
TaskBar.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
IsMouseOverStartButton()
{
CoordMode, Mouse, Screen
MouseGetPos, , , win
WinGetClass, class, ahk_id %win%
return class = "button"
}
GetTaskbarDirection()
{
WinGetPos X, Y, Width, Height, ahk_class Shell_TrayWnd
x := (x + x + width) / 2
y := (y + y + height) / 2
if(x < 0.1 * A_ScreenWidth)
return 1
if(x > 0.9 * A_ScreenWidth)
return 2
if(y < 0.1 * A_ScreenHeight)
return 3
if(y > 0.9 * A_ScreenHeight)
return 4
if(IsFullscreen("A", false, false))
return -1
return 0
}
IsMouseOverTaskList()
{
CoordMode, Mouse, Screen
WinGetPos , X, Y, , , ahk_class Shell_TrayWnd
if(WinVer >= WIN_7)
ControlGetPos , TaskListX, TaskListY, TaskListWidth, TaskListHeight, MSTaskListWClass1, ahk_class Shell_TrayWnd
else
ControlGetPos , TaskListX, TaskListY, TaskListWidth, TaskListHeight, MSTaskSwWClass1, ahk_class Shell_TrayWnd
;Transform to screen coordinates
TaskListX += X
TaskListY += Y
MouseGetPos, x, y
z := GetTaskBarDirection()
if(z >= 1 && z <= 4)
return IsMouseOverTaskbar() && IsInArea(x, y, TaskListX, TaskListY, TaskListWidth, TaskListHeight)
return false
}
IsMouseOverTray()
{
CoordMode, Mouse, Screen
MouseGetPos, x, y
ControlGetPos , TrayX, TrayX, TrayWidth, TrayHeight, ToolbarWindow321, ahk_class Shell_TrayWnd
z := GetTaskBarDirection()
if(z >= 1 && z <= 4)
return IsMouseOverTaskbar() && IsInArea(x, y, TrayX, TrayY, TrayWidth, TrayHeight)
return false
}
IsMouseOverClock()
{
CoordMode, Mouse, Screen
MouseGetPos, , , , ControlUnderMouse
result := false
if(ControlUnderMouse = "TrayClockWClass1")
result := true
Debug("IsMouseOverClock()? " result)
return result
}
IsMouseOverShowDesktop()
{
CoordMode, Mouse, Screen
MouseGetPos, x, y
ControlGetPos , ShowDesktopX, ShowDesktopY, ShowDesktopWidth, ShowDesktopHeight, TrayShowDesktopButtonWClass1, ahk_class Shell_TrayWnd
z := GetTaskBarDirection()
if(z >= 1 && z <= 4)
return IsMouseOverTaskbar() && IsInArea(x,y,ShowDesktopX,ShowDesktopY,ShowDesktopWidth,ShowDesktopHeight)
return false
}
IsMouseOverTaskbar()
{
CoordMode, Mouse, Screen
MouseGetPos, , , WindowUnderMouseID
WinGetClass, winclass, ahk_id %WindowUnderMouseID%
result := false
if(winclass = "Shell_TrayWnd")
result := true
return result
}
IsMouseOverFreeTaskListSpace()
{
static result, IsRunning
CoordMode, Mouse, Screen
SetWinDelay 0
SetKeyDelay 0
SetMouseDelay 0
if(!IsMouseOverTaskList())
{
IsRunning := false
return false
}
if(WinVer < WIN_7)
{
x := HitTest()
return x < 0
}
IsRunning := true
Click Right
result := 0
x := 0
while(x < 50)
{
if(WinExist("ahk_class #32768"))
{
result := true
break
}
else if(WinActive("ahk_id DV2ControlHost"))
{
result := false
break
}
x += 10
sleep 10
}
while(WinExist("ahk_class #32768") || WinActive("ahk_class DV2ControlHost"))
Send {Esc}
IsRunning := false
return result
}
;Middle click on taskbutton -> close task
TaskButtonClose()
{
if(IsMouseOverTaskList())
{
click right
while(!IsContextMenuActive() && WinVer < WIN_7)
sleep 10
if(WinVer >= WIN_7) ;wait until the menu has slided out
{
prevx := 0
prevy := 0
x := 1
y := 1
while(true)
{
if(IsContextMenuActive())
{
Send {Esc}
return true
}
if(WinActive("ahk_class DV2ControlHost"))
break
Sleep 10
}
while(prevx != x || prevy != y)
{
prevx := x
prevy := y
WinGetPos x, y, , , ahk_class DV2ControlHost
Sleep 10
}
}
Send {up}{enter}
return false
}
return true
}