-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathborders.ahk
117 lines (93 loc) · 2.23 KB
/
borders.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
/*
###########################
borders v1.0 #
By Henrybk #
###########################
##################################
Licensed Under MIT License #
##################################
*/
removeBorders(hwnd) {
if (hWnd) {
if (WindowHasBorders(hWnd)) {
windowRemoveBorders(hwnd)
}
}
return
}
addBorders(hwnd) {
if (hWnd) {
if (!WindowHasBorders(hWnd)) {
windowAddBorders(hwnd)
}
}
return
}
ToogleBorders(hwnd) {
if (hWnd) {
if (WindowHasBorders(hWnd)) {
windowRemoveBorders(hwnd)
} else {
windowAddBorders(hwnd)
}
}
return
}
windowAddBorders(hwnd) {
; Add borders back
window := WinGetPosWindow(hWnd)
WinSet, Style, +0xC00000, ahk_id %hWnd%
WinSet, Style, +0x40000, ahk_id %hWnd%
WinMove, ahk_id %hWnd%,, window.x, window.y, window.w, window.h
return
}
windowRemoveBorders(hwnd) {
; Remove borders
client := WinGetPosClient(hWnd)
WinSet, Style, -0xC00000, ahk_id %hWnd%
WinSet, Style, -0x40000, ahk_id %hWnd%
WinMove, ahk_id %hWnd%,, client.x, client.y, client.w, client.h
return
}
WindowHasBorders(hwnd) {
if (!hwnd) {
return 0
}
WinGet, WindowStyle, Style, ahk_id %hWnd%
if (WindowStyle & +0xC00000) {
return 1
} else {
return 0
}
}
WinGetPosClient(hwnd) {
if (!hwnd) {
return {x: 0, y: 0, w: 0, h: 0}
}
WinGetPos, rx, ry, rw, rh, ahk_id %hwnd%
; subtract window frame
WinGet style, style, ahk_id %hwnd%
if style & 0xc00000 { ; bordered window, get client area
SysGet cap, 4 ; caption height
SysGet bw, 32 ; border width
SysGet bh, 33 ; border height
rx += bw, ry += (cap + bh), rw -= (bh * 2), rh -= (cap + bh * 2)
}
return {x: rx, y: ry, w: rw, h: rh}
}
WinGetPosWindow(hwnd) {
if (!hwnd) {
return {x: 0, y: 0, w: 0, h: 0}
}
WinGetPos, rx, ry, rw, rh, ahk_id %hwnd%
; subtract window frame
WinGet style, style, ahk_id %hwnd%
if (style & 0xc00000) { ; bordered window, get client area
} else {
SysGet cap, 4 ; caption height
SysGet bw, 32 ; border width
SysGet bh, 33 ; border height
rx -= bw, ry -= (cap + bh), rw += (bh * 2), rh += (cap + bh * 2)
}
return {x: rx, y: ry, w: rw, h: rh}
}