-
Notifications
You must be signed in to change notification settings - Fork 3
/
mwm.ahk
217 lines (179 loc) · 7.41 KB
/
mwm.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
#Requires AutoHotkey v2
#SingleInstance force
#WinActivateForce
#Warn VarUnset, Off
A_MaxHotkeysPerInterval := 1000
KeyHistory(0), ListLines(false), ProcessSetPriority("H")
#include *i lib\miguru\miguru.ahk
#include *i lib\Popup.ahk
GroupAdd("MIGURU_AUTOFLOAT", "Microsoft Teams-Benachrichtigung" " ahk_exe Teams.exe" )
GroupAdd("MIGURU_AUTOFLOAT", "Microsoft Teams-Notification" " ahk_exe Teams.exe" )
GroupAdd("MIGURU_AUTOFLOAT", " ahk_exe QuickLook.exe" )
GroupAdd("MIGURU_AUTOFLOAT", " ahk_exe outlook.exe" " ahk_class MsoSplash" )
GroupAdd("MIGURU_AUTOFLOAT", " ahk_exe explorer.exe" " ahk_class OperationStatusWindow")
GroupAdd("MIGURU_AUTOFLOAT", " ahk_exe taskmgr.exe" )
GroupAdd("MIGURU_AUTOFLOAT", "Calculator" " ahk_exe ApplicationFrameHost.exe" )
GroupAdd("MIGURU_AUTOFLOAT", " ahk_exe zeal.exe" )
GroupAdd("MIGURU_AUTOFLOAT", "Window Spy for AHKv2" )
GroupAdd("MIGURU_AUTOFLOAT", "WinMerge" )
GroupAdd("MIGURU_DECOLESS", " ahk_exe qutebrowser.exe" )
GroupAdd("MIGURU_DECOLESS", " ahk_exe alacritty.exe" )
GroupAdd("MIGURU_DECOLESS", " ahk_exe msrdc.exe" " ahk_class RAIL_WINDOW" )
GroupAdd("MIGURU_IGNORE", " ahk_exe msrdc.exe" )
GroupAdd("MIGURU_IGNORE", "WinUI Desktop" " ahk_exe PowerToys.Peek.UI.exe" " ahk_class WinUIDesktopWin32WindowClass")
if !IsSet(MiguruWM) {
prog := RegExReplace(A_ScriptName, "i)\.ahk$", ".exe")
if FileExist(prog) {
Run(prog)
}
ExitApp()
}
layouts := [
TallLayout(),
WideLayout(),
FullscreenLayout(),
FloatingLayout(),
ColumnLayout(),
RowLayout(),
ThreeColumnLayout(),
TwoPaneLayout(),
SpiralLayout(),
]
mwm := { __Call: (name, params*) => } ; Ignore requests while mwm isn't ready yet
mwm := MiguruWM({
layout: layouts[1],
showPopup: (text, opts) => Popup(text, ObjMerge({
duration: 500,
showIcon: true,
}, opts)),
focusIndicator: HazeOver(),
;; …see https://github.com/imawizard/MiguruWM/wiki/Configuration
})
MiguruWM.SetupTrayMenu()
; Use Alt as modifier but disable it if pressed alone
mod1 := "Alt"
Alt::return
; Keybindings .............................................................{{{1
#Hotif GetKeyState(mod1, "P") and !GetKeyState("Shift", "P")
*1::mwm.Do("focus-workspace", { workspace: 1 })
*2::mwm.Do("focus-workspace", { workspace: 2 })
*3::mwm.Do("focus-workspace", { workspace: 3 })
*4::mwm.Do("focus-workspace", { workspace: 4 })
*5::mwm.Do("focus-workspace", { workspace: 5 })
*6::mwm.Do("focus-workspace", { workspace: 6 })
*7::mwm.Do("focus-workspace", { workspace: 7 })
*8::mwm.Do("focus-workspace", { workspace: 8 })
*9::mwm.Do("focus-workspace", { workspace: 9 })
*w::mwm.Do("focus-monitor", { monitor: 1 })
*e::mwm.Do("focus-monitor", { monitor: 2 })
*r::mwm.Do("focus-monitor", { monitor: 3 })
*j::mwm.Do("focus-window", { target: "next" })
*k::mwm.Do("focus-window", { target: "previous" })
*m::mwm.Do("focus-window", { target: "master" })
*l::mwm.Set("master-size", { delta: 0.025 })
*h::mwm.Set("master-size", { delta: -0.025 })
*,::mwm.Set("master-count", { delta: 1 })
*.::mwm.Set("master-count", { delta: -1 })
*t::mwm.Do("float-window", { value: "toggle" }), mwm.Do("center-window")
*p::OpenSearch()
*q::Reload()
*Enter::mwm.Do("swap-window", { with: "master" })
*Space::mwm.Do("cycle-layout", { value: layouts })
*vk01::MoveActiveWindow()
*vk02::ResizeActiveWindow()
*F1::Logger.ToggleConsole()
*F2::mwm.Do("get-workspace-info")
*F3::mwm.Do("get-monitor-info")
#Hotif GetKeyState(mod1, "P") and GetKeyState("Shift", "P")
*1::mwm.Do("send-to-workspace", { workspace: 1 })
*2::mwm.Do("send-to-workspace", { workspace: 2 })
*3::mwm.Do("send-to-workspace", { workspace: 3 })
*4::mwm.Do("send-to-workspace", { workspace: 4 })
*5::mwm.Do("send-to-workspace", { workspace: 5 })
*6::mwm.Do("send-to-workspace", { workspace: 6 })
*7::mwm.Do("send-to-workspace", { workspace: 7 })
*8::mwm.Do("send-to-workspace", { workspace: 8 })
*9::mwm.Do("send-to-workspace", { workspace: 9 })
*w::mwm.Do("send-to-monitor", { monitor: 1 })
*e::mwm.Do("send-to-monitor", { monitor: 2 })
*r::mwm.Do("send-to-monitor", { monitor: 3 })
*j::mwm.Do("swap-window", { with: "next" })
*k::mwm.Do("swap-window", { with: "previous" })
*c::try WinClose("A")
*q::ExitApp()
*Enter::OpenTerminal()
*Space::ResetLayout()
; ..........................................................................}}}
; Helper functions ........................................................{{{1
ResetLayout() {
defaults := mwm.Options
mwm.Set("layout", { value: defaults.layout })
mwm.Set("master-size", { value: defaults.masterSize })
mwm.Set("master-count", { value: defaults.masterCount })
mwm.Set("padding", { value: defaults.padding })
mwm.Set("spacing", { value: defaults.spacing })
}
GetSHAppFolderPath(hwnd := 0) {
if !hwnd {
hwnd := WinExist("A")
}
res := ""
app := ComObject("Shell.Application")
for window in app.Windows {
if window && window.hwnd == hwnd {
res := window.Document.Folder.Self.Path
break
}
}
return res
}
OpenTerminal() {
wd := EnvGet("USERPROFILE")
if WinGetProcessName("A") == "explorer.exe" {
path := GetSHAppFolderPath()
if path && Substr(path, 1, 2) !== "::" {
wd := path
}
}
Run("wt.exe -d " wd)
}
OpenTaskView() {
Send("#{Tab}")
}
OpenSearch() {
Send("#s")
}
ShowDesktop() {
Send("#d")
}
MoveActiveWindow() {
MouseGetPos(, , &hwnd)
if !hwnd {
return
}
WinActivate("ahk_id" hwnd)
mwm.Do("float-window", { hwnd: hwnd, value: true })
PostMessage(WM_SYSCOMMAND, SC_MOVE, , , "ahk_id" hwnd)
PostMessage(WM_KEYDOWN, VK_LEFT, , , "ahk_id" hwnd)
PostMessage(WM_KEYUP, VK_LEFT, , , "ahk_id" hwnd)
PostMessage(WM_KEYDOWN, VK_RIGHT, , , "ahk_id" hwnd)
PostMessage(WM_KEYUP, VK_RIGHT, , , "ahk_id" hwnd)
KeyWait("vk01")
Send("{vk01 Up}")
}
ResizeActiveWindow() {
MouseGetPos(, , &hwnd)
if !hwnd {
return
}
WinActivate("ahk_id" hwnd)
mwm.Do("float-window", { hwnd: hwnd, value: true })
PostMessage(WM_SYSCOMMAND, SC_SIZE, , , "ahk_id" hwnd)
PostMessage(WM_KEYDOWN, VK_DOWN, , , "ahk_id" hwnd)
PostMessage(WM_KEYUP, VK_DOWN, , , "ahk_id" hwnd)
PostMessage(WM_KEYDOWN, VK_RIGHT, , , "ahk_id" hwnd)
PostMessage(WM_KEYUP, VK_RIGHT, , , "ahk_id" hwnd)
KeyWait("vk02")
Send("{vk01 Up}")
}
; ..........................................................................}}}