-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.ahk
executable file
·308 lines (265 loc) · 5.74 KB
/
main.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
308
#SingleInstance Force
#installKeybdHook
#KeyHistory 0
#Notrayicon
#Persistent
#NoEnv
#MaxThreads 255
; #Warn
SendMode Input
SetWorkingDir %A_ScriptDir% ; Consistent starting directory
CoordMode, Mouse, Screen
CoordMode, Pixel, Screen
SetBatchLines, -1
SetWinDelay, 2
SetTitleMatchMode, 2
Run, grid.ahk,,, gridPid
Run, w10_taskbar.ahk
#include config.ahk
; ------------------- window decorations
; Uncomment this if you want a hotkey to set it for every window
; !+r::GoSub, AdjustAllWindows
; Init
GoSub, HookWindow
; Run it once for every window
GoSub, AdjustAllWindows
Return
HookWindow:
Gui +LastFound
hWnd := WinExist()
DllCall( "RegisterShellHookWindow", UInt,hWnd )
MsgNum := DllCall( "RegisterWindowMessage", Str,"SHELLHOOK" )
OnMessage( MsgNum, "ShellMessage" )
ShellMessage(wParam,lParam) {
If (wParam = 1) { ; HSHELL_WINDOWCREATED := 1
Sleep, 10
AdjustWindow(lParam)
}
}
Return
; Adjust Window
AdjustWindow(id) {
WinId := id
WinTitle := id = "A" ? "A" : "ahk_id " . id
; check if the window is in alt-tab menu
WinGet, WinExStyle, ExStyle, %WinTitle%
If (WinExStyle & 0x80) {
Return
}
; Match classes and/or processes
WinGetClass, WinClass, %WinTitle%
WinGet, WinProcess, ProcessName, %WinTitle%
; Processes/classes go here
; WinSet, Style, -0x40000, A ; WS_THICKFRAME
; Explorer caption
;If WinClass In % "CabinetWClass"
;If WinProcess In % "explorer.exe"
;{
; WinSet, Style, -0xC00000, %WinTitle%
;}
; qBitTorrent
If WinProcess In % "qbittorrent.exe"
{
WinSet, Style, -0xC00000, %WinTitle%
WinSet, Style, -0x40000, %WinTitle%
}
; Anki
If WinProcess In % "anki.exe"
{
WinSet, Style, -0xC00000, %WinTitle%
WinSet, Style, -0x40000, %WinTitle%
}
; Notepad caption
If WinProcess In % "notepad.exe"
{
WinSet, Style, -0xC00000, %WinTitle%
}
; Mintty
If WinProcess In % "mintty.exe"
{
WinSet, Style, -0xC00000, %WinTitle%
WinSet, Style, -0x40000, %WinTitle%
}
; Firefox
; Customize Toolbar > "Title Bar" on
If WinProcess In % "firefox.exe"
{
Winset, Style, -0x40000, %WinTitle%
WinSet, Style, -0xC00000, %WinTitle%
}
; Chromium
;If WinProcess In % "chrome.exe"
;{
; WinSet, Style, -0xC00000, %WinTitle%
; WinSet, Style, -0x40000, %WinTitle%
;}
; Qutebrowser thickframe
If WinProcess In % "qutebrowser.exe"
{
;WinSet, Style, -0xC00000, %WinTitle%
WinSet, Style, -0x40000, %WinTitle%
}
; Nomacs
; If WinProcess In % "nomacs.exe"
; {
; WinSet, Style, -0xC00000, %WinTitle%
; Winset, Style, -0x40000, %WinTitle%
; }
; qimgv
If WinProcess In % "qimgv.exe"
{
WinSet, Style, -0xC00000, %WinTitle%
Winset, Style, -0x40000, %WinTitle%
}
; SumatraPDF
If WinProcess In % "SumatraPDF.exe"
{
winset, style, -0xc00000, %wintitle%
winset, style, -0x40000, %wintitle%
}
; sioyek
If WinProcess In % "sioyek.exe"
{
winset, style, -0xc00000, %wintitle%
winset, style, -0x40000, %wintitle%
}
; Volume mixer
If WinProcess In % "SndVol.exe"
{
WinSet, Style, -0xC00000, %WinTitle%
Winset, Style, -0x40000, %WinTitle%
}
; Sil-Q
If WinProcess In % "sil.exe"
{
WinSet, Style, -0xC00000, %WinTitle%
Winset, Style, -0x40000, %WinTitle%
}
; Uncomment this and comment section above
; if you want it to work on every window
; WinSet, Style, -0xC00000, %WinTitle%
}
AdjustAllWindows:
WinGet, id, list,,, Program Manager
Loop, %id% {
AdjustWindow(id%A_Index%)
}
Return
; ------------------- mappings
; toggle caption
#^f::
WinGetTitle, currentWindow, A
IfWinExist %currentWindow%
{
WinSet, Style, ^0xC00000
}
return
; toggle border (thickframe)
#^c::
WinGetTitle, currentWindow, A
IfWinExist %currentWindow%
{
WinSet, Style, ^0x40000, A
; WinSet, Style, ^0x800000, A
}
return
; swap caps and esc (IME-compatible)
$sc03A::sc001
$Esc::CapsLock
;^sc03A::!sc029
; ff
#If WinActive("ahk_exe firefox.exe")
^e::^l ;focus urlbar
^#e::^#e
#if
; foobar
#v::
run, C:\Software\players\Foobar2000\foobar2000.exe
return
; volume mixer
#m::
run, SndVol.exe
sleep 200
WinMove, A,,,, 1440
return
; stb-imv
#If WinActive("ahk_exe imv.exe")
a::Left
d::Right
l::Right
h::Left
+Space::
Send {Left}
return
b::l
; preserve default behaviour
#a::#a
#d::#d
^#h::^#h
^#b::^#b
^#l::^#l
!#h::^#h
!#l::^#l
#if
; imageglass
#If WinActive("ahk_exe ImageGlass.exe")
$a::Left
$d::Right
$Space::
Send {Right}
return
$+Space::
Send {Left}
return
$b::h
$f::
WinGet, active, ID, A
Send {F10}
WinActivate, ahk_id %active%
return
#if
; RWin
!^LWin::
Keywait Ctrl
Keywait Alt
Send {RWin}
return
; toggle border on active window
#c::
DetectHiddenWindows, On
IfWinExist, activeborder.ahk ahk_class AutoHotkey
WinClose, activeborder.ahk ahk_class AutoHotkey
else IfWinNotExist, activeborder.ahk ahk_class AutoHotkey
Run, activeborder.ahk
DetectHiddenWindows, Off
return
; make a window be always on top
#^w::
Winset, Alwaysontop, , A
return
; window transparency
#^t::
WinSet, Transparent, Off, A
return
#!t::
WinSet, Transparent, 210, A
return
#If WinActive("ahk_exe alacritty.exe")
#!t::
WinSet, Transparent, 230, A
return
#if
; mute/unmute mic
; either 6 or 7
;#^a::
; SoundSet, +1, MASTER, Mute, 6
;return
; reload the script
!#r::
WinClose, grid.ahk,,, gridPid
Reload
return
; ------------------- source other modules
#include tile.ahk
#include moveandresize.ahk
#include w10.ahk