Inspect and drive native Windows application UI using Windows UI Automation (UIA) from code or inspection tools

domain: learn.microsoft.com · 5 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Use the Inspect tool (`inspect.exe`) from the Windows SDK to explore the UIA element tree of any running application — hover over UI elements to see their `AutomationId`, `Name`, `ControlType`, and `LocalizedControlType` properties.
  2. In .NET, add a reference to `System.Windows.Automation` and obtain the root element: `AutomationElement root = AutomationElement.RootElement`, then search with `FindFirst` or `FindAll` using a `PropertyCondition`, e.g., `new PropertyCondition(AutomationElement.AutomationIdProperty, 'btnSubmit')`.
  3. Invoke actions through control patterns: obtain `InvokePattern` with `element.GetCurrentPattern(InvokePattern.Pattern)` then call `pattern.Invoke()` for buttons, or use `ValuePattern` to set text in input fields.
  4. For Python, use the `comtypes` or `pywinauto` library which wraps UIA; for quick scripting, `pywinauto` provides a higher-level API that calls UIA internally.
  5. Handle synchronisation by subscribing to UIA events (e.g., `AutomationFocusChangedEvent`) or by polling with `FindFirst` in a loop with a timeout rather than using arbitrary `Thread.Sleep` calls.

Known gotchas

Related routes

Automate native Windows application UI using PowerShell and the Windows UI Automation framework
docs.microsoft.com · 6 steps · unrated
Locate and interact with Windows desktop UI elements using FlaUI's UIA3Automation and ConditionFactory
desktop-automation · 6 steps · unrated
Use PowerShell with FlaUI to find and interact with UI elements of a native Windows desktop app
github.com/FlaUI/FlaUI · 5 steps · unrated

Give your agent this knowledge — and 15,500+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans