-
Notifications
You must be signed in to change notification settings - Fork 4
/
TilingWindowManager -1440.ahk.bak
410 lines (343 loc) · 13.9 KB
/
TilingWindowManager -1440.ahk.bak
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
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
#Persistent
#SingleInstance force
;; tiling window manager for windows 7-10 designed for 1 or 2 monitors arranging
;; windows in the following pattern with configurable window sizes and borders:
;; _________ _________
;; | | | | |___| <- primary monitor
;; | | | | | |
;; '---i-----' '-----i---'
;; todo override windows move keys, eg, win + left
;; -- window sizing options
;; override system, here you can define a default offset and specific program offsets
;; this will allow you to setup for custom themes and programs that wont behave
;; I tried to make this work with WinGetPosEx but even that had many faults
global windowOverrides := Object()
windowOverrides["default"] := Object()
windowOverrides["default"]["left"] := -8
windowOverrides["default"]["top"] := 0
windowOverrides["default"]["width"] := +16
windowOverrides["default"]["height"] := +8
windowOverrides["ONENOTE.EXE"] := Object()
windowOverrides["ONENOTE.EXE"]["left"] := 0
windowOverrides["ONENOTE.EXE"]["top"] := 0
windowOverrides["ONENOTE.EXE"]["width"] := 0
windowOverrides["ONENOTE.EXE"]["height"] := 0
windowOverrides["Steam.exe"] := Object()
windowOverrides["Steam.exe"]["left"] := 1
windowOverrides["Steam.exe"]["top"] := 1
windowOverrides["Steam.exe"]["width"] := -2
windowOverrides["Steam.exe"]["height"] := -2
windowOverrides["explorer.exe"] := Object()
windowOverrides["explorer.exe"]["left"] := -8
windowOverrides["explorer.exe"]["top"] := 0
windowOverrides["explorer.exe"]["width"] := +16
windowOverrides["explorer.exe"]["height"] := +8
windowOverrides["atom.exe"] := Object()
windowOverrides["atom.exe"]["left"] := -8
windowOverrides["atom.exe"]["top"] := 0
windowOverrides["atom.exe"]["width"] := +16
windowOverrides["atom.exe"]["height"] := +8
windowOverrides["chrome.exe"] := Object()
windowOverrides["chrome.exe"]["left"] := -8
windowOverrides["chrome.exe"]["top"] := 0
windowOverrides["chrome.exe"]["width"] := +16
windowOverrides["chrome.exe"]["height"] := +8
windowOverrides["firefox.exe"] := Object()
windowOverrides["firefox.exe"]["left"] := -6
windowOverrides["firefox.exe"]["top"] := 0
windowOverrides["firefox.exe"]["width"] := +12
windowOverrides["firefox.exe"]["height"] := +6
windowOverrides["putty.exe"] := Object()
windowOverrides["putty.exe"]["left"] := -4
windowOverrides["putty.exe"]["top"] := 0
windowOverrides["putty.exe"]["width"] := +8
windowOverrides["putty.exe"]["height"] := +4
windowOverrides["WinSCP.exe"] := Object()
windowOverrides["WinSCP.exe"]["left"] := -8
windowOverrides["WinSCP.exe"]["top"] := 0
windowOverrides["WinSCP.exe"]["width"] := +16
windowOverrides["WinSCP.exe"]["height"] := +8
windowOverrides["pidgin.exe"] := Object()
windowOverrides["pidgin.exe"]["left"] := -8
windowOverrides["pidgin.exe"]["top"] := 0
windowOverrides["pidgin.exe"]["width"] := +16
windowOverrides["pidgin.exe"]["height"] := +8
windowOverrides["ApplicationFrameHost.exe"] := Object()
windowOverrides["ApplicationFrameHost.exe"]["left"] := -8
windowOverrides["ApplicationFrameHost.exe"]["top"] := 0
windowOverrides["ApplicationFrameHost.exe"]["width"] := +16
windowOverrides["ApplicationFrameHost.exe"]["height"] := +8
windowOverrides["Code.exe"] := Object()
windowOverrides["Code.exe"]["left"] := 0
windowOverrides["Code.exe"]["top"] := 0
windowOverrides["Code.exe"]["width"] := 0
windowOverrides["Code.exe"]["height"] := 0
windowOverrides["Code - Insiders.exe"] := Object()
windowOverrides["Code - Insiders.exe"]["left"] := 0
windowOverrides["Code - Insiders.exe"]["top"] := 0
windowOverrides["Code - Insiders.exe"]["width"] := 0
windowOverrides["Code - Insiders.exe"]["height"] := 0
windowOverrides["slack.exe"] := Object()
windowOverrides["slack.exe"]["left"] := 0
windowOverrides["slack.exe"]["top"] := 0
windowOverrides["slack.exe"]["width"] := 0
windowOverrides["slack.exe"]["height"] := 0
windowOverrides["Spotify.exe"] := Object()
windowOverrides["Spotify.exe"]["left"] := 0
windowOverrides["Spotify.exe"]["top"] := 0
windowOverrides["Spotify.exe"]["width"] := 0
windowOverrides["Spotify.exe"]["height"] := 0
windowOverrides["Photoshop.exe"] := Object()
windowOverrides["Photoshop.exe"]["left"] := 0
windowOverrides["Photoshop.exe"]["top"] := 0
windowOverrides["Photoshop.exe"]["width"] := 0
windowOverrides["Photoshop.exe"]["height"] := 0
windowOverrides["EXCEL.EXE"] := Object()
windowOverrides["EXCEL.EXE"]["left"] := 0
windowOverrides["EXCEL.EXE"]["top"] := 0
windowOverrides["EXCEL.EXE"]["width"] := 0
windowOverrides["EXCEL.EXE"]["height"] := 0
windowOverrides["Discord.exe"] := Object()
windowOverrides["Discord.exe"]["left"] := 0
windowOverrides["Discord.exe"]["top"] := 0
windowOverrides["Discord.exe"]["width"] := 0
windowOverrides["Discord.exe"]["height"] := 0
windowOverrides["Ripcord.exe"] := Object()
windowOverrides["Ripcord.exe"]["left"] := 0
windowOverrides["Ripcord.exe"]["top"] := 0
windowOverrides["Ripcord.exe"]["width"] := 0
windowOverrides["Ripcord.exe"]["height"] := 0
windowOverrides["Battle.net.exe"] := Object()
windowOverrides["Battle.net.exe"]["left"] := 0
windowOverrides["Battle.net.exe"]["top"] := 0
windowOverrides["Battle.net.exe"]["width"] := 0
windowOverrides["Battle.net.exe"]["height"] := 0
windowOverrides["Messenger.exe"] := Object()
windowOverrides["Messenger.exe"]["left"] := 0
windowOverrides["Messenger.exe"]["top"] := 0
windowOverrides["Messenger.exe"]["width"] := 0
windowOverrides["Messenger.exe"]["height"] := 0
SysGet, MonitorCount, MonitorCount
SysGet, MonitorPrimary, MonitorPrimary
;;MsgBox, Monitor Count:`t%MonitorCount%`nPrimary Monitor:`t%MonitorPrimary%
Loop, %MonitorCount%
{
SysGet, MonitorName, MonitorName, %A_Index%
SysGet, Monitor, Monitor, %A_Index%
SysGet, MonitorWorkArea, MonitorWorkArea, %A_Index%
;;MsgBox, Monitor:`t#%A_Index%`nName:`t%MonitorName%`nLeft:`t%MonitorLeft% (%MonitorWorkAreaLeft% work)`nTop:`t%MonitorTop% (%MonitorWorkAreaTop% work)`nRight:`t%MonitorRight% (%MonitorWorkAreaRight% work)`nBottom:`t%MonitorBottom% (%MonitorWorkAreaBottom% work)
}
;; what happens when:
;; -- TaskbarMontior1 Montitor2
;; -- TaskbarMonitor2 Monitor1
;; -- Monitor1 TaskbarMonitor2
;; -- Monitor2 TaskbarMontior1
;; * Monitor2: -1920
;; * Monitor1: 0
;; size of space between windows
windowBorder = 10
;; width of the large windows that appear closest to the center of the screen
windowLeftWidth = 1260
;; height of the small top right window
windowRightSmallTopHeight = 700
topWindowTriWidth = 843
;; monitor geometry
;; todo: automate this
monitorWidth = 2560
monitorHeight = 1440
taskbarHeight = 30
;;calculated variables used below
windowHeightTall := monitorHeight - (windowBorder * 2)
windowHeightTallTaskbar := monitorHeight - (windowBorder * 2) - taskbarHeight
windowRightWidth := monitorWidth - windowLeftWidth - (windowBorder * 3)
newZero := 0
;; _________
;; | | | -- BotLeft
;; | | |
;; '----i----'
;; _________
;; | xx | |
;; | xx | |
;; '----i----'
botLeftWidth := windowLeftWidth
botLeftHeight := windowHeightTallTaskbar
botLeftLeft := windowBorder
botLeftTop := windowBorder
;; _________
;; | | | -- BotRight
;; | | |
;; '----i----'
;; _________
;; | | xx |
;; | | xx |
;; '----i----'
botRightWidth := monitorWidth - windowLeftWidth - (windowBorder * 3)
botRightHeight := windowHeightTallTaskbar
botRightLeft := windowLeftWidth + (windowBorder * 2)
botRightTop := windowBorder
;; _________
;; | | | -- BotRightTop
;; | | |
;; '----i----'
;; _________
;; | |_xx_|
;; | | |
;; '----i----'
BotRightTopWidth := monitorWidth - windowLeftWidth - (windowBorder * 3)
BotRightTopHeight := windowRightSmallTopHeight
BotRightTopLeft := windowLeftWidth + (windowBorder * 2)
BotRightTopTop := windowBorder
;; _________
;; | | | -- BotRightBottom
;; | | |
;; '----i----'
;; _________
;; | |____|
;; | | xx |
;; '----i----'
BotRightBottomtWidth := monitorWidth - windowLeftWidth - (windowBorder * 3)
BotRightBottomHeight := monitorHeight - windowRightSmallTopHeight - (windowBorder * 3) - taskbarHeight
BotRightBottomLeft := windowLeftWidth + (windowBorder * 2)
BotRightBottomTop := windowRightSmallTopHeight + (windowBorder * 2)
;; _________
;; | xx | | -- TopLeft
;; | xx | |
;; '----i----'
;; _________
;; | | |
;; | | |
;; '----i----'
TopLeftWidth := windowLeftWidth
TopLeftHeight := windowHeightTall
TopLeftLeft := windowBorder
TopLeftTop := windowBorder - monitorHeight
;; _________
;; | | xx | -- TopRight
;; | | xx |
;; '----i----'
;; _________
;; | | |
;; | | |
;; '----i----'
TopRightWidth := monitorWidth - windowLeftWidth - (windowBorder * 3)
TopRightHeight := windowHeightTall
TopRightLeft := windowLeftWidth + (windowBorder * 2)
TopRightTop := windowBorder - monitorHeight
;; _________
;; | x| | | -- TriTopLeft
;; | | | |
;; '---------'
;; _________
;; | | |
;; | | |
;; '----i----'
TriTopLeftWidth := topWindowTriWidth
TriTopLeftHeight := windowHeightTall
TriTopLeftLeft := windowBorder
TriTopLeftTop := windowBorder - monitorHeight
;; _________
;; | | x | | -- TriTopMiddle
;; | | | |
;; '---------'
;; _________
;; | | |
;; | | |
;; '----i----'
TriTopMiddleWidth := topWindowTriWidth - windowBorder
TriTopMiddleHeight := windowHeightTall
TriTopMiddleLeft := (windowBorder * 2) + topWindowTriWidth
TriTopMiddleTop := windowBorder - monitorHeight
;; _________
;; | | | x| -- TriTopRight
;; | | | |
;; '---------'
;; _________
;; | | |
;; | | |
;; '----i----'
TriTopRightWidth := topWindowTriWidth
TriTopRightHeight := windowHeightTall
TriTopRightLeft := (windowBorder * 2) + (topWindowTriWidth * 2)
TriTopRightTop := windowBorder - monitorHeight
;; simplified winmove function call
ResizeWinMine(Width = 0,Height = 0, MyLeft = 0, MyTop = 0)
{
WinGetPos,X,Y,W,H,A
If %Width% = 0
Width := W
If %Height% = 0
Height := H
tmpArray := windowOverrides
;;PrintArray(tmpArray)
noOverrides = 1
For index, value in tmpArray{
;;MsgBox, index:`t%index%`n
if(WinActive("ahk_exe" . index)){
MyLeft := MyLeft + windowOverrides[index]["left"]
MyTop := MyTop + windowOverrides[index]["top"]
Width := Width + windowOverrides[index]["width"]
Height := Height + windowOverrides[index]["height"]
noOverrides = 0
;;MsgBox, MyLeft:`t%MyLeft%`n | MyTop:`t%MyTop% | Width:`t%Width% | Height:`t%Height%
}
}
if(noOverrides == 1) {
MyLeft := MyLeft + windowOverrides["default"]["left"]
MyTop := MyTop + windowOverrides["default"]["top"]
Width := Width + windowOverrides["default"]["width"]
Height := Height + windowOverrides["default"]["height"]
;;MsgBox, test2
}
WinMove,A,,%MyLeft%,%MyTop%,%Width%,%Height%
}
;; configure menu
Menu, Tray, Icon , icon.ico
Menu, tray, NoStandard
Menu, Tray, Add, Exit, Exit
Menu, Tray, Add
Menu, Tray, Add, &Left Left Small, LeftLeft
Menu, Tray, Add, &Left Right Large, LeftRight
Menu, Tray, Add
Menu, Tray, Add, &Right Left Large, LeftLarge
Menu, Tray, Add, &Right Right Small, RightSmall
Menu, Tray, Add
Menu, Tray, Add, &Right Right Small Top, RightSmallTop
Menu, Tray, Add, &Right Right Small Bottom, RightSmallBottom
#1::ResizeWinMine(TriTopLeftWidth, TriTopLeftHeight, TriTopLeftLeft, TriTopLeftTop)
#2::ResizeWinMine(TriTopMiddleWidth, TriTopMiddleHeight, TriTopMiddleLeft, TriTopMiddleTop)
#3::ResizeWinMine(TriTopRightWidth, TriTopRightHeight, TriTopRightLeft, TriTopRightTop)
#q::ResizeWinMine(TopLeftWidth, TopLeftHeight, TopLeftLeft, TopLeftTop)
#w::ResizeWinMine(TopRightWidth, TopRightHeight, TopRightLeft, TopRightTop)
#a::ResizeWinMine(botLeftWidth, botLeftHeight, botLeftLeft, botLeftTop)
#s::ResizeWinMine(botRightWidth, botRightHeight, botRightLeft, botRightTop)
#e::ResizeWinMine(BotRightTopWidth, BotRightTopHeight, BotRightTopLeft, BotRightTopTop)
#d::ResizeWinMine(BotRightBottomtWidth, BotRightBottomHeight, BotRightBottomLeft, BotRightBottomTop)
;; menu items
;; for the menu we have to activate the previos window (may not be perfect in all case)
;; because the tray popup itself counts as a window
Exit:
ExitApp
LeftLeft:
Send !{Esc} ; Activate previous window
ResizeWinMine(LeftLeftWidth,LeftLeftHeight, LeftLeftLeft, LeftLeftTop)
return
LeftRight:
Send !{Esc} ; Activate previous window
ResizeWinMine(LeftRightWidth,LeftRightHeight, LeftRightLeft, LeftRightTop)
return
LeftLarge:
Send !{Esc} ; Activate previous window
ResizeWinMine(RightLeftWidth,RightLeftHeight, RightLeftLeft, RightLeftTop)
return
RightSmall:
Send !{Esc} ; Activate previous window
ResizeWinMine(RightRightWidth,RightRightHeight, RightRightLeft, RightRightTop)
return
RightSmallTop:
Send !{Esc} ; Activate previous window
ResizeWinMine(RightRightTopWidth,RightRightTopHeight, RightRightTopLeft, RightRightTopTop)
return
RightSmallBottom:
Send !{Esc} ; Activate previous window
ResizeWinMine(RightRightBotWidth,RightRightBotHeight, RightRightBotLeft, RightRightBotTop)
return