def get_actual_rect(hwnd):
"""Gets correct dimensions of a DWM controlled window
"Retrieves the extended frame bounds rectangle in screen space".
Windows 10 reports (technically) incorrect window dimensions,
so this is used to obtain the correct window dimensions.
Args:
hwnd: The handle to the window from which the attribute data is retrieved.
Returns:
A windows RECT structure of the correct window dimensions.
"""
rect = RECT()
DWMWA_EXTENDED_FRAME_BOUNDS = 9
dwmapi.DwmGetWindowAttribute(HWND(hwnd),
DWORD(DWMWA_EXTENDED_FRAME_BOUNDS),
ctypes.byref(rect),
ctypes.sizeof(rect))
# actual_x1 = rect.left
# actual_y1 = rect.top
# actual_x2 = rect.right
# actual_y2 = rect.bottom
# return [actual_x1, actual_y1, actual_x2, actual_y2]
return rect
评论列表
文章目录