-
Notifications
You must be signed in to change notification settings - Fork 73
/
Copy pathWinMovePos.ahk
93 lines (72 loc) · 1.55 KB
/
WinMovePos.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
/*
Func: WinMovePos
Moves window to area on the screen
Parameters:
winHwnd - Hwnd of target window
pos - Desired window position
Returns:
Moves winHwnd to specified pos
Examples:
WinMovePos(myWindowHwnd, "TopRight")
= Window myWindowHwnd will be in the topright corner the screen
Required libs:
WinGetPos.ahk
*/
WinMovePos(winHwnd, pos) {
WinGetPos( winHwnd, X0, Y0, W0, H0, 0)
If (pos = "Center") {
X := (A_ScreenWidth / 2) - (W0 / 2)
Y := (A_ScreenHeight / 2) - (H0 / 2)
}
If (pos = "Top") {
X := X0
Y := 0
}
If (pos = "Bottom") {
X := X0
Y := (A_ScreenHeight) - H0
If InStr(A_OSVersion, "10.") and !WinBorderless(winHwnd)
Y += 7
}
If (pos = "Left") {
X := 0
Y := Y0
If InStr(A_OSVersion, "10.") and !WinBorderless(winHwnd)
X -= 7
}
If (pos = "TopLeft") {
X := 0
Y := 0
If InStr(A_OSVersion, "10.") and !WinBorderless(winHwnd)
X -= 7
}
If (pos = "BottomLeft") {
X := 0
Y := (A_ScreenHeight) - H0
If InStr(A_OSVersion, "10.") and !WinBorderless(winHwnd) {
Y += 7
X -= 7
}
}
If (pos = "Right") {
X := (A_ScreenWidth - W0)
Y := Y0
If InStr(A_OSVersion, "10.") and !WinBorderless(winHwnd)
X += 7
}
If (pos = "TopRight") {
X := (A_ScreenWidth) - W0
Y := 0
If InStr(A_OSVersion, "10.") and !WinBorderless(winHwnd)
X += 7
}
If (pos = "BottomRight") {
X := (A_ScreenWidth) - W0
Y := (A_ScreenHeight) - H0
If InStr(A_OSVersion, "10.") and !WinBorderless(winHwnd) {
Y += 7
X += 7
}
}
WinMove, % "ahk_id" winHwnd,, % X, % Y
}