-
Notifications
You must be signed in to change notification settings - Fork 72
/
Copy pathWinMoveGetPos.ahk
80 lines (66 loc) · 1.33 KB
/
WinMoveGetPos.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
/*
Func: WinMoveGetPos
Returns x and y coordinates to move window to area on the screen
Parameters:
winHwnd - Hwnd of target window
pos - Desired window position
outputX - Output for X
outputY - Output for Y
Returns:
X&Y coordinates to move winHwnd to selected pos
Examples:
+ Add example
Required libs:
WinGetPos.ahk
*/
WinMoveGetPos(winHwnd, pos, ByRef outputX:="", ByRef outputY:="") {
DetectHiddenWindows, On
WinGetPos( winHwnd, X0, Y0, W0, H0, 0)
If (pos = "Center")
{
nX := (A_ScreenWidth / 2) - (W0 / 2)
nY := (A_ScreenHeight / 2) - (H0 / 2)
}
If (pos = "Top")
{
nX := (A_ScreenWidth / 2) - (W0 / 2)
nY := 0
}
If (pos = "Bottom")
{
nX := (A_ScreenWidth / 2) - (W0 / 2)
nY := (A_ScreenHeight) - H0
}
If (pos = "Left")
{
nX := 0
nY := (A_ScreenHeight / 2) - (H0 / 2)
}
If (pos = "TopLeft") or (pos = "Top-Left")
{
nX := 0
nY := 0
}
If (pos = "BottomLeft") or (pos = "Bottom-Left")
{
nX := 0
nY := (A_ScreenHeight) - H0
}
If (pos = "Right")
{
nX := (A_ScreenWidth - W0)
nY := (A_ScreenHeight / 2) - (H0 / 2)
}
If (pos = "TopRight") or (pos = "Top-Right")
{
nX := (A_ScreenWidth) - W0
nY := 0
}
If (pos = "BottomRight") or (pos = "Bottom-Right")
{
nX := (A_ScreenWidth) - W0
nY := (A_ScreenHeight) - H0
}
outputX := nX
outputY := nY
}