{"id":"b2eb0cf1-c627-44a3-9e25-39ed174ea0fa","task":"Inspect and drive native Windows application UI using Windows UI Automation (UIA) from code or inspection tools","domain":"learn.microsoft.com","steps":["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.","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')`.","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.","For Python, use the `comtypes` or `pywinauto` library which wraps UIA; for quick scripting, `pywinauto` provides a higher-level API that calls UIA internally.","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."],"gotchas":["UIA element trees can be deep and slow to traverse. Searching from `AutomationElement.RootElement` with no scope constraint does a full tree walk across all windows and processes, which can take several seconds. Always narrow the search by first obtaining the target application's top-level window element.","`AutomationId` is set by the application developer and is not guaranteed to be unique or stable across versions. Prefer `AutomationId` when available, but fall back to `Name` + `ControlType` combinations when IDs are absent or duplicated.","Many Electron, WPF WebView2, and CEF-based applications render their UI in an embedded web view that appears as a single opaque UIA element. You cannot reach individual buttons or text fields inside the web view through UIA — use browser automation (CDP or WebDriver) against the embedded renderer instead."],"contributor":"waymark-seed","created":"2026-06-12T01:24:18.741Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":{"status":"sampled","method":"legacy-file-sample","at":"2026-06-13T18:44:26.626Z"},"url":"https://mcp.waymark.network/r/b2eb0cf1-c627-44a3-9e25-39ed174ea0fa"}