diff --git a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClient/MS/Internal/Automation/HwndProxyElementProvider.cs b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClient/MS/Internal/Automation/HwndProxyElementProvider.cs index 5c33d6fc70b..cf13ed68e2e 100644 --- a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClient/MS/Internal/Automation/HwndProxyElementProvider.cs +++ b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClient/MS/Internal/Automation/HwndProxyElementProvider.cs @@ -574,7 +574,7 @@ WindowVisualState IWindowProvider.VisualState WindowInteractionState IWindowProvider.InteractionState { - // Note: we should consider Implementing InteractionState by finding the gui thread of the + // Note: we should consider Implementing InteractionState by finding the gui thread of the // process and mapping ThreadState and WaitReason to a WindowInteractionState get { @@ -1457,6 +1457,21 @@ private static bool IsWindowReallyEnabled( NativeMethods.HWND hwnd ) // Check that a window is visible, and has a non-empty rect private static bool IsWindowReallyVisible( NativeMethods.HWND hwnd ) { + // check for visibility overrides + // The UIA team says: + // * UIA_WindowVisibilityOverridden property was added in 2011 for Win8.1 + // * "I'm not actually sure it is documented publicly." + // * "It's a window property that if its handle value is 1 it's ForceVisible, and if it's 2 it's ForceHidden." + IntPtr visibilityOverride = UnsafeNativeMethods.GetProp(hwnd, "UIA_WindowVisibilityOverridden"); + if (visibilityOverride == new IntPtr(1)) + { + return true; + } + else if (visibilityOverride == new IntPtr(2)) + { + return false; + } + if(!SafeNativeMethods.IsWindowVisible(hwnd)) { return false; diff --git a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClient/MS/Win32/UnsafeNativeMethods.cs b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClient/MS/Win32/UnsafeNativeMethods.cs index 4e34d485888..78af001e011 100644 --- a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClient/MS/Win32/UnsafeNativeMethods.cs +++ b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClient/MS/Win32/UnsafeNativeMethods.cs @@ -365,5 +365,12 @@ internal struct MENUBARINFO [DllImport("gdi32.dll", CharSet = CharSet.Auto, SetLastError = true)] internal static extern bool DeleteObject(IntPtr hrgn); + // + // Window Property Functions + // + + [DllImport("user32.dll", CharSet = CharSet.Unicode)] + internal static extern IntPtr GetProp(IntPtr hwnd, string name); + } }