- The WinGetClientPos function shows what I believe to be the correct X/Y values.
- Window Spy shows what I believe to be the correct width/height values.
- I provide a custom function below which I believe shows all of the correct values.
- Note: Window Spy does not show any X/Y values for the active window's client position, there is a gap where it could be added, and I believe it would only take about 2 changes to the code, to add it in.
Code: Select all
q:: ;test WinGetClientPos
hWnd := WinGetID("A")
;note: 'client pos'
WinGetClientPos(vWinX, vWinY, vWinW, vWinH, "A")
vCoords1 := Format("x{} y{} w{} h{}", vWinX, vWinY, vWinW, vWinH)
;note: 'pos client'
JEE_WinGetPosClient(hWnd, vWinX, vWinY, vWinW, vWinH)
vCoords2 := Format("x{} y{} w{} h{}", vWinX, vWinY, vWinW, vWinH)
vWinX := vWinY := "__"
GetClientSize(hWnd, vWinW, vWinH) ;from WindowSpy.ahk
vCoords3 := Format("x{} y{} w{} h{}", vWinX, vWinY, vWinW, vWinH)
MsgBox(vCoords1 " AHK v2" "`r`n" vCoords2 " custom" "`r`n" vCoords3 " Window Spy")
return
JEE_WinGetPosClient(hWnd, ByRef vWinX, ByRef vWinY, ByRef vWinW, ByRef vWinH)
{
VarSetCapacity(RECT, 16, 0)
DllCall("user32\GetClientRect", Ptr,hWnd, Ptr,&RECT)
DllCall("user32\ClientToScreen", Ptr,hWnd, Ptr,&RECT)
vWinX := NumGet(&RECT, 0, "Int"), vWinY := NumGet(&RECT, 4, "Int")
vWinW := NumGet(&RECT, 8, "Int"), vWinH := NumGet(&RECT, 12, "Int")
}
GetClientSize(hWnd, ByRef w := "", ByRef h := "")
{
VarSetCapacity(rect, 16)
DllCall("GetClientRect", "ptr", hWnd, "ptr", &rect)
w := NumGet(rect, 8, "int")
h := NumGet(rect, 12, "int")
}