-
Notifications
You must be signed in to change notification settings - Fork 72
/
Copy pathGetWindowPos.ahk
32 lines (28 loc) · 980 Bytes
/
GetWindowPos.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
/*
Recupera las coordenadas y dimensiones de la ventana especificada.
Parámetros:
hWnd: El identificador de la ventana.
Return:
0 = Error.
[obj] = Si tuvo éxito devuelve un objeto con las claves X,Y,W,H, ClientW y ClientH.
Ejemplo:
For Key, Pos in GetWindowPos(WinExist('ahk_class Notepad'))
Str .= Key . ':`t' . Pos . '`n'
MsgBox(Str)
*/
GetWindowPos(hWnd)
{
Local RECT
VarSetCapacity(RECT, 16, 0)
If (!DllCall('User32.dll\GetWindowRect', 'Ptr', hWnd, 'UPtr', &RECT))
Return (FALSE)
Local Pos := {}
Pos.X := NumGet(&RECT , 'Int')
Pos.Y := NumGet(&RECT + 4, 'Int')
Pos.W := NumGet(&RECT + 8, 'Int') - Pos.X
Pos.H := NumGet(&RECT + 12, 'Int') - Pos.Y
DllCall('User32.dll\GetClientRect', 'Ptr', hWnd, 'UPtr', &RECT)
Pos.ClientW := NumGet(&RECT + 8, 'Int')
Pos.ClientH := NumGet(&RECT + 12, 'Int')
Return (Pos)
}