From c36acb878b81786620398c7a2d4a2099ed1edac7 Mon Sep 17 00:00:00 2001 From: ynerant Date: Fri, 11 Jul 2025 15:25:24 +0200 Subject: [PATCH] Fix control bitmap bounds with DWM enabled Signed-off-by: Emmy D'Anello --- uiautomation/uiautomation.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/uiautomation/uiautomation.py b/uiautomation/uiautomation.py index ac2003c..131d02e 100644 --- a/uiautomation/uiautomation.py +++ b/uiautomation/uiautomation.py @@ -3517,6 +3517,10 @@ def FromControl(control: 'Control', x: int = 0, y: int = 0, width: int = 0, heig handle = control.NativeWindowHandle if handle: pRect = control.BoundingRectangle + toplevelHandle = GetAncestor(handle, GAFlag.Root) + if toplevelHandle and toplevelHandle == handle: + if DwmIsCompositionEnabled(): + pRect = DwmGetWindowExtendFrameBounds(handle) or pRect left = rect.left - pRect.left + x top = rect.top - pRect.top + y right = left + width