Can 'AutomationElement.GetClickablePoint' be made to ignore a topmost transparent click-through overlay?

Molchanov, Pavel 20 Reputation points
2026-09-23T10:50:34.49+00:00

I have a full-screen, topmost WPF overlay window ('AllowsTransparency=true') that renders occasional elements but is otherwise fully transparent. Empty areas return 'HTTRANSPARENT` from 'WM_NCHITTEST', so real mouse click correctly falls through to the windows underneath.

However, my UI Automation tests fail: 'AutomationElement.GetClickablePoint()' on the elements underneath the overlay throws a 'Win32Exception' ("Access is denied"), because 'WindowFromPoint' ignores 'HTTRANSPARENT' and returns the overlay HWND instead of the element's window.

Is there any supported way to make 'GetClickablePoint' (or the underlying UIA hit-test) treat this window as transparent without applying 'WS_EX_TRANSPARENT' to the whole window (that would break clicks on those elements that can be rendered there)?

Regarding this window:

WindowUtils.SetWindowPos(handle, InsertAfterHandles.HWND_TOPMOST, 0, 0, 0, 0, WindowPositionFlags.ZOrder);

var w = new Window {

Content = view,

WindowStartupLocation = WindowStartupLocation.Manual,

Background = new SolidColorBrush(Colors.Transparent),

BorderBrush = new SolidColorBrush(Colors.Transparent),

Foreground = new SolidColorBrush(Colors.Transparent),

BorderThickness = new Thickness(0),

ResizeMode = ResizeMode.NoResize,

Focusable = false,

AllowsTransparency = true,

ShowActivated = true,

WindowStyle = WindowStyle.None,

ShowInTaskbar = false,

Visibility = Visibility.Collapsed,

};

Windows development | WinUI
0 comments No comments

Answer accepted by question author
Gatlin Le (WICLOUD CORPORATION) 805 Reputation points Microsoft External Staff Moderator
2026-09-23T11:06:07.15+00:00

Hi @Molchanov, Pavel ,

Thanks for sharing the configuration. I understand that the overlay's empty areas need to remain click-through while its rendered controls stay interactive. I have not found a documented public UIA API that exempts that HWND from GetClickablePoint hit-testing while preserving this selective interaction.

Mouse hit-testing and UIA clickable-point detection are not interchangeable. HTTRANSPARENT is a WM_NCHITTEST response, not a documented UIA exclusion flag. Separately, the layered-window documentation explains that hit testing of a layered window is based on its shape and transparency, so areas whose alpha value is zero let mouse messages through. Since AllowsTransparency=true produces a layered window, a click passing through does not, by itself, establish how UIA will resolve that point.

I tested a standalone WPF reproduction, but did not reproduce Access is denied. With the overlay hidden, and with it transparent while the HTTRANSPARENT hook was enabled, GetClickablePoint returned a point. With the hook disabled, and with an opaque overlay, it threw NoClickablePointException. InvokePattern.Invoke() activated the target button in every configuration tested.

The screenshots below show the complete comparison and the transparent-overlay case with the hook enabled:

Overview

transparent-hook

One observation may be relevant: the runner (PID 8632) and the overlay (PID 10808) ran in separate processes, yet the runner's native WindowFromPoint returned the target HWND rather than the overlay. The harness records the native HWND lookup and the UIA point lookup separately, so this does not establish the execution path GetClickablePoint takes internally.

The test ran on Windows build 26200 and .NET 10.0.12, with an MTA UIA runner. All three processes were elevated at the same high integrity level, with uiAccess=false. It therefore did not test a lower-integrity runner accessing a higher-integrity target or overlay. Not reproducing access denied under matched privileges does not rule out a security-boundary issue in your environment; the UI Automation Security Overview provides the relevant background. The harness also uses ShowActivated=false, covers only the primary screen, and does not verify physical mouse click-through.

The GetClickablePoint documentation lists NoClickablePointException when no clickable point is available. Its transparent-window example concerns controls inside that window, not controls underneath a separate overlay. It does not establish that your access-denied failure is by design.

To distinguish these errors, add this diagnostic method to your test class and call it from your existing UIA worker thread:

using System;
using System.ComponentModel;
using System.Windows.Automation;

static void CheckClickablePoint(AutomationElement target)
{
    try
    {
        var point = target.GetClickablePoint();
        Console.WriteLine($"Clickable point: {point.X}, {point.Y}");
    }
    catch (NoClickablePointException exception)
    {
        Console.WriteLine("No clickable point was found.");
        Console.WriteLine(exception);
    }
    catch (Win32Exception exception)
    {
        Console.WriteLine($"NativeErrorCode: {exception.NativeErrorCode}");
        Console.WriteLine($"HRESULT: 0x{exception.HResult:X8}");
        Console.WriteLine(exception);
    }
}

This is a diagnostic, not a fix. Compare the same target with the overlay visible and actually hidden, keeping privileges unchanged. If hiding it removes the error, that helps isolate the overlay's involvement; if the error remains, the investigation should extend beyond overlay hit-testing.

If your test only needs to activate a control, its supported InvokePattern.Invoke() may avoid the clickable-point lookup. It does not replace a physical-click test or bypass access restrictions.

Could you share:

  • The diagnostic output, including the stack trace and any inner exception.
  • Your Windows/.NET versions, target UI framework, and WM_NCHITTEST hook implementation.
  • Each process's elevation/UIAccess settings, especially whether the runner has a lower integrity level than the target or overlay.

Remove private paths or application data from the output. These details will help locate the failing call and determine whether the local test missed a relevant configuration or security boundary; they are not a recommendation to change your privilege settings.

If you found my explanation above was truly helpful or informative to you, I would greatly appreciate it if you could follow this guidance so others with the same issue could benefit as well.

Thank you.

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.