-
Notifications
You must be signed in to change notification settings - Fork 4
/
TilingWindowManagerSurface.ahk.bak
375 lines (303 loc) · 13.4 KB
/
TilingWindowManagerSurface.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
#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
;; size of space between windows
windowBorder = 15
;; width of the large windows that appear closest to the center of the screen
windowLeftWidth = 1770
;; height of the small top right window
windowRightSmallTopHeight = 1100
;; height of the top left main window
windowLeftSmallTopHeight = 1500
;; monitor geometry
;; todo: automate this
monitorBorderRight = 1920
monitorBorderLeft = 0
monitorWidth = 3000
monitorHeight = 2000
taskbarHeight = 52
monitorWidthLeft = 1440
monitorheightRight = 2560
;; 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"] := -11
windowOverrides["default"]["top"] := 0
windowOverrides["default"]["width"] := +23
windowOverrides["default"]["height"] := 0
windowOverrides["firefox.exe"] := Object()
windowOverrides["firefox.exe"]["left"] := -9
windowOverrides["firefox.exe"]["top"] := 0
windowOverrides["firefox.exe"]["width"] := +19
windowOverrides["firefox.exe"]["height"] := +10
windowOverrides["Spotify.exe"] := Object()
windowOverrides["Spotify.exe"]["left"] := +4
windowOverrides["Spotify.exe"]["top"] := 0
windowOverrides["Spotify.exe"]["width"] := -4
windowOverrides["Spotify.exe"]["height"] := -12
windowOverrides["pidgin.exe"] := Object()
windowOverrides["pidgin.exe"]["left"] := -15
windowOverrides["pidgin.exe"]["top"] := 0
windowOverrides["pidgin.exe"]["width"] := +33
windowOverrides["pidgin.exe"]["height"] := +12
windowOverrides["Photoshop.exe"] := Object()
windowOverrides["Photoshop.exe"]["left"] := -2
windowOverrides["Photoshop.exe"]["top"] := -2
windowOverrides["Photoshop.exe"]["width"] := 0
windowOverrides["Photoshop.exe"]["height"] := -10
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["slack.exe"] := Object()
windowOverrides["slack.exe"]["left"] := 0
windowOverrides["slack.exe"]["top"] := 0
windowOverrides["slack.exe"]["width"] := -2
windowOverrides["slack.exe"]["height"] := -14
windowOverrides["ConEmu64.exe"] := Object()
windowOverrides["ConEmu64.exe"]["left"] := -15
windowOverrides["ConEmu64.exe"]["top"] := 0
windowOverrides["ConEmu64.exe"]["width"] := +30
windowOverrides["ConEmu64.exe"]["height"] := +2
windowOverrides["emacs.exe"] := Object()
windowOverrides["emacs.exe"]["left"] := -15
windowOverrides["emacs.exe"]["top"] := 0
windowOverrides["emacs.exe"]["width"] := +30
windowOverrides["emacs.exe"]["height"] := +2
windowOverrides["Code.exe"] := Object()
windowOverrides["Code.exe"]["left"] := -12
windowOverrides["Code.exe"]["top"] := 0
windowOverrides["Code.exe"]["width"] := +24
windowOverrides["Code.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"] := -16
windowOverrides["explorer.exe"]["top"] := 0
windowOverrides["explorer.exe"]["width"] := +32
windowOverrides["explorer.exe"]["height"] := +10
windowOverrides["atom.exe"] := Object()
windowOverrides["atom.exe"]["left"] := -16
windowOverrides["atom.exe"]["top"] := 0
windowOverrides["atom.exe"]["width"] := +32
windowOverrides["atom.exe"]["height"] := +10
windowOverrides["chrome.exe"] := Object()
windowOverrides["chrome.exe"]["left"] := -16
windowOverrides["chrome.exe"]["top"] := 0
windowOverrides["chrome.exe"]["width"] := +32
windowOverrides["chrome.exe"]["height"] := +10
windowOverrides["firefox.exe"] := Object()
windowOverrides["firefox.exe"]["left"] := -12
windowOverrides["firefox.exe"]["top"] := 0
windowOverrides["firefox.exe"]["width"] := +20
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"] := -16
windowOverrides["WinSCP.exe"]["top"] := 0
windowOverrides["WinSCP.exe"]["width"] := +32
windowOverrides["WinSCP.exe"]["height"] := +10
windowOverrides["pidgin.exe"] := Object()
windowOverrides["pidgin.exe"]["left"] := -16
windowOverrides["pidgin.exe"]["top"] := 0
windowOverrides["pidgin.exe"]["width"] := +32
windowOverrides["pidgin.exe"]["height"] := +10
*/
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
;;calculated variables used below
windowHeightTall := monitorHeight - (windowBorder * 2)
windowHeightTallTaskbar := monitorHeight - (windowBorder * 2) - taskbarHeight
windowRightWidth := monitorWidth - windowLeftWidth - (windowBorder * 3)
newLeftWindowWidth := monitorWidthLeft - (windowBorder * 2)
newLeftWindowTopHeight := 800
newLeftWindowBotHeight := 1715
vertWindowWidth := monitorHeight - (windowBorder * 2)
vertWindowWTopHeight := 2000
vertWindowWBotHeight := monitorWidth - vertWindowWTopHeight - (windowBorder * 2) - taskbarHeight
newZero := 0
;; ___ _________
;; | x | | |___| -- LeftLeft
;; | | | | |
;; '---i '-----i---'
LeftLeftWidth := (monitorWidthLeft * 2) - (windowBorder * 2)
LeftLeftHeight := newLeftWindowTopHeight * 2
LeftLeftLeft := (newZero - (monitorWidthLeft * 2) + 15)
LeftLeftTop := - 600
;; ____ _________
;; | | | |___| -- LeftRight
;; | x | | | |
;; '---i '-----i---'
LeftRightWidth := (monitorWidthLeft * 2) - (windowBorder * 2)
LeftRightHeight := newLeftWindowBotHeight * 2 + (windowBorder * 3)
LeftRighteft := (newZero - (monitorWidthLeft * 2) + 15)
LeftRightTop := - 600 + (newLeftWindowTopHeight * 2) + windowBorder
;; _________ _________
;; | | | | |___| -- RightLeft
;; | | | | X | |
;; '---i-----' '-----i---'
RightLeftWidth := windowLeftWidth
RightLeftHeight := windowHeightTallTaskbar
RightLeftLeft := windowBorder
RightLeftTop := windowBorder
;; _________ _________
;; | | | | x |___| -- RightLeftTop
;; | | | |_____| |
;; '---i-----' '-----i---'
RightLeftTopWidth := windowLeftWidth
RightLeftTopHeight := windowLeftSmallTopHeight
RightLeftTopLeft := windowBorder
RightLeftTopTop := windowBorder
;; _________ _________
;; | | | | |___| -- RightLeftBottom
;; | | | |_____| |
;; '---i-----' '--X--i---'
RightLeftBotWidth := windowLeftWidth
RightLeftBotHeight := monitorHeight - taskbarHeight - (windowBorder * 3) - windowLeftSmallTopHeight
RightLeftBotLeft := windowBorder
RightLeftBotTop := windowLeftSmallTopHeight + (windowBorder * 2)
;; _________ _________
;; | | | | | | -- RightRight
;; | | | | | X |
;; '---i-----' '-----i---'
RightRightWidth := windowRightWidth
RightRightHeight := windowHeightTallTaskbar
RightRightLeft := windowLeftWidth + (windowBorder * 2)
RightRightTop := windowBorder
;; _________ _________
;; | | | | |_X_| -- RightRightTop
;; | | | | | |
;; '---i-----' '-----i---'
RightRightTopWidth := windowRightWidth
RightRightTopHeight := windowRightSmallTopHeight
RightRightTopLeft := windowLeftWidth + (windowBorder * 2)
RightRightTopTop := windowBorder
;; _________ _________
;; | | | | |___| -- RightRightTop
;; | | | | | X |
;; '---i-----' '-----i---'
RightRightBotWidth := windowRightWidth
RightRightBotHeight := monitorHeight - taskbarHeight - (windowBorder * 3) - windowRightSmallTopHeight
RightRightBotLeft := windowLeftWidth + (windowBorder * 2)
RightRightBotTop := windowRightSmallTopHeight + (windowBorder * 2)
;; 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 , Television.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
;; _________ _________
;; | | | | e |_r_|
;; | q | w | |_____| f |
;; '-----i---' '--d--i---'
;; keyboard shortcuts
#q::ResizeWinMine(RightLeftWidth,RightLeftHeight, RightLeftLeft, RightLeftTop)
#w::ResizeWinMine(RightRightWidth,RightRightHeight, RightRightLeft, RightRightTop)
;#r::ResizeWinMine(RightRightTopWidth,RightRightTopHeight, RightRightTopLeft, RightRightTopTop)
;#f::ResizeWinMine(RightRightBotWidth,RightRightBotHeight, RightRightBotLeft, RightRightBotTop)
#e::ResizeWinMine(RightLeftTopWidth,RightLeftTopHeight, RightLeftTopLeft, RightLeftTopTop)
#d::ResizeWinMine(RightLeftBotWidth,RightLeftBotHeight, RightLeftBotLeft, RightLeftBotTop)
#z::ResizeWinMine(LeftLeftWidth,LeftLeftHeight, LeftLeftLeft, LeftLeftTop)
#x::ResizeWinMine(LeftRightWidth,LeftRightHeight, LeftRighteft, LeftRightTop)
#r::ResizeWinMine(vertWindowWidth, vertWindowWTopHeight, 15, 15)
#f::ResizeWinMine(vertWindowWidth, vertWindowWBotHeight, 15, (vertWindowWTopHeight + (windowBorder * 2)))
;; 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