-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTb_Shadow.ahk
307 lines (270 loc) · 8.47 KB
/
Tb_Shadow.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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
#NoEnv
#SingleInstance force
#Persistent
SetBatchLines, -1
SetWinDelay, -1 ; Makes the below move faster/smoother.
Process, Priority,, High
SysGet, MonitorWorkArea, MonitorWorkArea
SysGet, MonitorArea, Monitor
CmenuArrayIds := []
MonitorWorkAreaWidth := MonitorWorkAreaRight - MonitorWorkAreaLeft
If (MonitorWorkAreaTop == 0)
{
TaskBarHeight := MonitorAreaBottom - MonitorWorkAreaBottom
TaskBarYPosition := MonitorWorkAreaBottom
}
Else
{
TaskBarHeight := MonitorWorkAreaTop - MonitorAreaTop
TaskBarYPosition := 0
}
Menu, Tray, Icon
Menu, Tray, NoStandard
Menu, Tray, Add, Run at Startup, strtup
Menu, Tray, Add, Reload, Reload_label
Menu, Tray, Add, Suspend, Suspend_label
Menu, Tray, Add, Default Shadow, DefaultShadow
Menu, Tray, Add, Bold Shadow, BoldShadow
Menu, Tray, Add, Exit, Exit_label
Menu, Tray, Check, Bold Shadow
IfExist, %A_Startup%/Tb_Shadow.lnk
Menu, Tray, Check, Run at Startup
Gui, Shadow1:New
Gui, +HwndIGUI1
Gui, -Caption +ToolWindow +Lastfound -Border +E0x08000000 +AlwaysOnTop
Gui, Color, FF00FF
Gui, Show, Center w%MonitorWorkAreaWidth% h%TaskBarHeight% y%TaskBarYPosition%, AHK GUI1
FrameShadow(IGUI1)
WinSet, TransColor, FF00FF, ahk_id %IGUI1%
WinSet, Bottom, , ahk_id %IGUI1%
Gui, Shadow2:New
Gui, +HwndIGUI2
Gui, -Caption +ToolWindow +Lastfound -Border +E0x08000000 +AlwaysOnTop
Gui, Color, FF00FF
Gui, Show, Center w%MonitorWorkAreaWidth% h%TaskBarHeight% y%TaskBarYPosition%, AHK GUI2
FrameShadow(IGUI2)
WinSet, TransColor, FF00FF, ahk_id %IGUI2%
WinSet, Bottom, , ahk_id %IGUI2%
Gui, Shadow3:New
Gui, +HwndIGUI3
Gui, -Caption +ToolWindow +Lastfound -Border +E0x08000000 +AlwaysOnTop
Gui, Color, FF00FF
Gui, Show, Center w%MonitorWorkAreaWidth% h%TaskBarHeight% y%TaskBarYPosition%, AHK GUI3
FrameShadow(IGUI3)
WinSet, TransColor, FF00FF, ahk_id %IGUI3%
WinSet, Bottom, , ahk_id %IGUI3%
Gui, ShadowRM:New
Gui, +HwndIGUIR
Gui, -Caption +ToolWindow +Lastfound -Border +E0x08000000
WinSet, TransColor, F2F2F2 0, ahk_id %IGUIR%
Gui, Color, F2F2F2
Gui,Margin,0,0
WinSet, ExStyle, +0x20, ahk_id %IGUIR%
WinSet, AlwaysOnTop, On, ahk_id %IGUIR%
SetTimer, LookForMenu, 100
Return
~LButton::
Gui, ShadowRM: Hide
WinSet, TransColor, F2F2F2 0, ahk_id %IGUIR%
Return
~RButton::
Gui, ShadowRM: Hide
WinSet, TransColor, F2F2F2 0, ahk_id %IGUIR%
Return
LookForMenu:
If (WinExist("ahk_class #32768"))
{
MouseGetPos , , , mId
WinGetClass, mClass, ahk_id %mid%
WinGet, winId, ID, ahk_class #32768
WinGetPos, x, y, w, h, ahk_id %winId%
If ((oldId != winId) && x && y && w && h)
{
Gui, ShadowRM: Hide
rmenuX := x
rmenuY := y
rmenuW := w ;- 2
rmenuH := h ;- 2
Gui, ShadowRM:Show, NA x%rmenuX% y%rmenuY% w%rmenuW% h%rmenuH%, AHK GUI3
FrameShadow(IGUIR)
WinSet, TransColor, F2F2F2 0, ahk_id %IGUIR%
WinSet, AlwaysOnTop, On, ahk_id %IGUIR%
transLevel := 0
If !(HasVal(CmenuArrayIds, winId))
{
CmenuArrayIds.push(winId)
}
for idx, wid in CmenuArrayIds
{
If WinExist("ahk_id " . wid)
WinSet, AlwaysOnTop, On, ahk_id %wid%
}
loop % 30
{
sleep 5
transLevel += 9
If transLevel > 255
transLevel := 255
WinSet, TransColor, F2F2F2 %transLevel%, ahk_id %IGUIR%
}
}
oldId := winId
}
Else
{
Gui, ShadowRM: Hide
WinSet, TransColor, F2F2F2 0, ahk_id %IGUIR%
CmenuArrayIds := []
}
Return
DefaultShadow:
Menu, Tray, Check, Default Shadow
Menu, Tray, UnCheck, Bold Shadow
Gui, Shadow3:Hide
Return
BoldShadow:
Menu, Tray, Check, Bold Shadow
Menu, Tray, UnCheck, Default Shadow
Gui, Shadow3:Show
Return
strtup:
Menu, Tray, Togglecheck, Run at Startup
IfExist, %A_Startup%/Tb_Shadow.lnk
FileDelete, %A_Startup%/Tb_Shadow.lnk
else FileCreateShortcut, % H_Compiled ? A_AhkPath : A_ScriptFullPath, %A_Startup%/Tb_Shadow.lnk
Return
Tray_SingleLclick:
msgbox You left-clicked tray icon
Return
Reload_label:
Reload
Return
Suspend_label:
loop 2
Settimer, Tray_SingleLclick, Off
Menu, Tray, Togglecheck, Suspend
Suspend
Return
Exit_label:
exitapp
Return
/*
WinSet_Click_Through - Makes a window unclickable.
I - ID of the window to set as unclickable.
T - The transparency to set the window. Leaving it blank will set it to 254. It can also be set On or Off. Any numbers lower then 0 or greater then 254 will simply be changed to 254.
If the window ID doesn't exist, it returns 0.
*/
WinSet_Click_Through(IDHWND, T="254") {
IfWinExist, % "ahk_id " I
{
If (T == "Off")
{
WinSet, AlwaysOnTop, Off, % "ahk_id " I
WinSet, Transparent, Off, % "ahk_id " I
WinSet, ExStyle, -0x20, % "ahk_id " I
}
Else
{
WinSet, AlwaysOnTop, On, % "ahk_id " I
If(T < 0 || T > 254 || T == "On")
T := 254
WinSet, Transparent, % T, % "ahk_id " I
WinSet, ExStyle, +0x20, % "ahk_id " I
}
}
Else
Return 0
}
ShadowBorder(handle)
{
DllCall("user32.dll\SetClassLongPtr", "ptr", handle, "int", -26, "ptr", DllCall("user32.dll\GetClassLongPtr", "ptr", handle, "int", -26, "uptr") | 0x20000)
}
FrameShadow(handle) {
DllCall("dwmapi\DwmIsCompositionEnabled","IntP",_ISENABLED) ; Get if DWM Manager is Enabled
if !_ISENABLED ; if DWM is not enabled, Make Basic Shadow
DllCall("SetClassLong","UInt",handle,"Int",-26,"Int",DllCall("GetClassLong","UInt",handle,"Int",-26)|0x20000)
else {
VarSetCapacity(_MARGINS,16)
NumPut(1,&_MARGINS,0,"UInt")
NumPut(1,&_MARGINS,4,"UInt")
NumPut(1,&_MARGINS,8,"UInt")
NumPut(1,&_MARGINS,12,"UInt")
DllCall("dwmapi\DwmSetWindowAttribute", "Ptr", handle, "UInt", 2, "Int*", 2, "UInt", 4)
DllCall("dwmapi\DwmExtendFrameIntoClientArea", "Ptr", handle, "Ptr", &_MARGINS)
}
}
FadeToTargetTrans(winId, targetValue := 255, startValue := 255)
{
Critical On
transIncrement := 10
If (targetValue != 255)
{
maxValue := startValue
loop % (abs(startValue - targetValue)/transIncrement)
{
sleep, 1
If (startValue > targetValue)
maxValue := maxValue - transIncrement
Else
maxValue := maxValue + transIncrement
WinSet, Transparent, %maxValue%, %winId%
}
}
Else ;target MUST be 255 opaque
{
init := startValue
loop % (ceil((255 - startValue)/transIncrement))
{
sleep, 1
init := init + transIncrement
WinSet, Transparent, %init%, %winId%
}
}
Critical Off
Return
}
HasVal(haystack, needle) {
for index, value in haystack
if (value == needle)
return True
if !(IsObject(haystack))
throw Exception("Bad haystack!", -1, haystack)
return False
}
;If !pToken := Gdip_Startup()
;{
; MsgBox, 48, gdiplus error!, Gdiplus failed to start. Please ensure you have gdiplus on your system
; ExitApp
;}
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;https://www.autohotkey.com/boards/viewtopic.php?p=264086&force_isolation=true#p264086
;#NoEnv
;CS_DROPSHADOW := 0x00020000
;ClassStyle := GetGuiClassStyle()
;Gui, New, +hwndHGUI
;SetGuiClassStyle(HGUI, ClassStyle | CS_DROPSHADOW)
;Gui, Show, x100 y100 w250 h200, Test 1
;SetGuiClassStyle(HGUI, ClassStyle)
;Gui, New
;Gui, Show, x400 y100 w250 h200, Test 2
;Gui, New, +hwndHGUI
;SetGuiClassStyle(HGUI, ClassStyle | CS_DROPSHADOW)
;Gui, Show, x700 y100 w250 h200, Test 3
;SetGuiClassStyle(HGUI, ClassStyle)
;Return
;GuiClose:
;GuiEscape:
;ExitApp
;GetGuiClassStyle() {
; Gui, GetGuiClassStyleGUI:Add, Text
; Module := DllCall("GetModuleHandle", "Ptr", 0, "UPtr")
; VarSetCapacity(WNDCLASS, A_PtrSize * 10, 0)
; ClassStyle := DllCall("GetClassInfo", "Ptr", Module, "Str", "AutoHotkeyGUI", "Ptr", &WNDCLASS, "UInt")
; ? NumGet(WNDCLASS, "Int")
; : ""
; Gui, GetGuiClassStyleGUI:Destroy
; Return ClassStyle
;}
;SetGuiClassStyle(HGUI, Style) {
; Return DllCall("SetClassLong" . (A_PtrSize = 8 ? "Ptr" : ""), "Ptr", HGUI, "Int", -26, "Ptr", Style, "UInt")
;}