[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M699KJVADW48GT9PQWNZVHV1":3,"skill-same:01M699KJVADW48GT9PQWNZVHV1":88},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":28,"publishedAt":50,"linkOnly":51,"markdownContent":52,"markdownBody":53,"frontMatter":54,"refName":55,"commitSha":56,"skillDirectory":57,"forksCount":58,"repositoryHtmlUrl":59,"repositoryHomepageUrl":6,"ownerHtmlUrl":60,"ownerBlogUrl":61,"ownerDescription":62,"updatedAt":63,"install":64,"resources":77},"01M699KJVADW48GT9PQWNZVHV1","winapp-ui-automation",null,"Inspect, drive, and verify a running Windows app UI via winapp ui (UI Automation): find elements, click, type, read text\u002Fvalues, wait for state, take screenshots in WinUI, WPF, WinForms, Win32, or Electron apps. Use to check, test, or act on a live app; for WinUI XAML internals, use winui-devtools.","microsoft\u002FwinappCli","microsoft","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F6154722?v=4","01M698VYDXZ6JW5WH3CRV650R8","Microsoft","01M699J7Q2FM9V32CFV0Q8VPF9",1381,"MIT","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FwinappCli\u002Fblob\u002Fmain\u002Fplugins\u002Fwinapp\u002Fskills\u002Fwinapp-ui-automation\u002FSKILL.md",[18,23],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000023","Skill与智能体开发","SCENARIO","使用场景",{"categoryNo":24,"categoryName":25,"taxonomyType":26,"taxonomyTypeDesc":27},"01JBSEEDCAT000000000000032","设计师","PROFESSION","适用职业",[29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49],"automation","winapp ui automation","ui","running","win32","live","wait","act","winforms","take","read","text","apps","devtools","inspect","wait for","click","app","xaml","screenshots","windows","2026-11-10 10:12:30",false,"---\nname: winapp-ui-automation\ndescription: \"Inspect, drive, and verify a running Windows app UI via winapp ui (UI Automation): find elements, click, type, read text\u002Fvalues, wait for state, take screenshots in WinUI, WPF, WinForms, Win32, or Electron apps. Use to check, test, or act on a live app; for WinUI XAML internals, use winui-devtools.\"\n---\n\n**If you can't run `winapp` yourself** (no shell, or the command is denied), give the user the exact `winapp` command(s) for their project instead of only describing the steps.\n\n## When to use\n- Inspecting a running Windows app's UI from the command line\n- AI agents interacting with Windows applications (clicking buttons, reading text, taking screenshots)\n- Verifying UI state during development or testing\n- Automating UI workflows without Playwright or Selenium\n- Debugging WinUI 3, WPF, WinForms, Win32, or Electron app UIs by what the user sees and can operate\n- Not for a WinUI 3 app's XAML internals (why a value or binding resolved the way it did, which XAML line made an element, live property edits, UI review comments): use `winui-devtools`\n\n## Prerequisites\nFor WinUI 3 XAML source\u002Ftree, bindings or dependency-property diagnosis and edits,\nuse the `winui-devtools` skill and `winapp devtools`. It requires an attached\ntarget or explicit authorization to inject with `--attach`; a PID alone is not\nconsent. An AutomationId works as a selector in both tools; generated slugs do\nnot transfer to DevTools. Continue using `winapp ui`\nfor cross-framework actions, screenshots, waits and accessibility.\n\nTo measure WinUI work while driving a scenario, use the\n`winapp-performance` skill to bracket UI actions with capture markers.\n\n- For UIA mode (any app): No setup needed — works with any running Windows app\n- For input-injecting verbs (`click`, `hover`, `drag`, `touch`, `pen`, `scroll --wheel`\u002F`--wheel-horizontal`, `send-keys --via send-input`): an **unlocked, interactive desktop** with the target window foregroundable. On a locked\u002Fsecure desktop they fail fast with `no_interactive_desktop`. The UIA-pattern verbs (`inspect`, `search`, `get-*`, `wait-for`, `set-value`, `invoke`, `scroll --direction\u002F--to`) are headless\u002Flocked-session friendly — prefer them in CI.\n- `screenshot` is **not** in that group: it always takes an exclusive turn, so it queues behind other UI workflows, and capture can need a usable interactive desktop — the engine restores the target if it is minimized, and falls back to foregrounding it when frame capture is unavailable or `--capture-screen` is used.\n- `--capture-screen` needs **exactly one window**. `-w \u003Chwnd>` gives it one: that window's screen region, including anything visibly on top of it. If `-a` matches several top-level or owned windows the command fails with `invalid_arguments` before capturing; run `winapp ui list-windows -a \u003Capp>` and retry with `-w \u003Chwnd>`.\n- **If other UI workflows may run at the same time**, set one workflow id per logical workflow (see below). Nothing breaks without it, but your commands will not be recognized as belonging together.\n\n## Coordinating with other UI workflows\n\nWindows has one foreground window, one keyboard focus, one cursor, and one input stream. `winapp ui`\ntherefore makes desktop-driving commands take **cooperative turns** so concurrent workflows cannot\nsteal each other's focus or dismiss each other's menus. That is always on. Read-only commands never\nwait.\n\nKeeping the desktop *across* commands is opt-in — without an id, each command is a one-shot that\nreleases the desktop the moment it finishes:\n\n```powershell\n# Set once per logical UI workflow — same value for cooperating calls, different values for\n# independent workflows (even from the same agent).\n$env:WINAPP_UI_WORKFLOW_ID = [guid]::NewGuid().ToString()\n```\n\nRules that matter when driving this from an agent:\n\n- **Each tool call usually gets a fresh shell**, and there is no process-ancestry fallback, so\n  commands are grouped ONLY by the id you inject. Without it every call is its own workflow.\n- **A workflow with an id keeps its turn for four seconds** after its last command. That covers\n  back-to-back commands in one script; it deliberately expires while you are reasoning. Treat it as\n  a fallback for when you cannot say you are done — not as the way to finish.\n- **Run `winapp ui yield` when you finish a known sequence.** It hands the desktop over immediately\n  instead of making a waiting workflow sit out a four-second grace nobody needs. Yielding twice, or\n  after the grace lapsed, is a harmless success.\n- **After a reasoning gap, replay your setup.** Another workflow may have used the desktop, so\n  reopen the menu \u002F re-navigate, re-resolve the element, then act. Do not assume transient UI\n  survived.\n- **Prefer one tight script over many round trips** for a known sequence: `winapp ui invoke View -w\n  $hwnd; winapp ui search \"Status bar\" -w $hwnd; winapp ui click \"Status bar\" -w $hwnd; winapp ui yield`.\n- **`record` shares the turn with its own workflow**, so same-workflow clicks and typing are captured\n  while it runs — but only if both commands carry the same id. A `record` with no id blocks everyone\n  else for its whole duration.\n- **Ordering is owner affinity, then FIFO.** An active workflow may keep issuing commands ahead of\n  others already waiting; once it yields or its grace expires, waiters are served in arrival order.\n- **Waiting is indefinite and cancellable.** After one second a notice on stderr says what holds the\n  desktop and for how long (silent under `--json` and `--quiet`); Ctrl+C exits `130` with error code\n  `cancelled` and the command never ran.\n- **There is no hard cap** — a long script, unbounded recording, or failure loop can block other\n  mutating workflows until it finishes or is stopped.\n\nCommands that never wait: `status`, `list-windows`, `inspect`, `search`, `get-*`, `wait-for`.\nCommands that wait for the turn but never take the desktop (headless\u002Flocked-session friendly):\n`set-value`, `scroll-into-view`, `scroll --direction`\u002F`--to`, `record`. They mutate the app, so they\nqueue behind another workflow. Inside your own workflow they overlap with other shared work — that\nis how `record` captures the `set-value` calls it is recording — but they still wait behind an\nearlier `DesktopExclusive` command of your own workflow, so a `click` followed by a `set-value` runs\nin the order you wrote it.\nCommands that take the desktop exclusively: `invoke`, `click`, `drag`, `hover`, `scroll --wheel`\u002F`--wheel-horizontal`,\n`touch`, `pen`, `focus`, `send-keys`, `screenshot`.\n\n```powershell\n# Finish a workflow deliberately rather than leaving the desktop reserved for four more seconds.\nwinapp ui yield\n```\n\n## Common patterns\n\n### Read within a specific container\n\n```powershell\nwinapp ui search \"Welcome to MyApp\" -a myapp --root MailRow --type Text --class-name TextBlock\nwinapp ui get-value Subject -a myapp --root MailRow --type TextBox\nwinapp ui wait-for Subject -a myapp --root MailRow --type Edit --value Ready --timeout 10000\nwinapp ui search --class-name CalendarSurface -a myapp   # no text selector needed\n```\n\nUse `--root`, `--type`, and `--class-name` together or separately on `search`,\n`get-property`, `get-value`, `wait-for`, and the commands that act on one\nselected element (`invoke`, `set-value`, `click`, `focus`, and so on; not `send-keys --target`).\n`--type` and `--class-name` work without a selector; commands other than `search` then need\nexactly one match, and an ambiguous match lists the first five with their slugs. `--root` alone is not a query. For `set-value`, pass `\"\"` as the selector.\nFor `click`, `hover`, `touch`, and `pen`, filters can't be combined with `--at` or `--path`. The root must be unique; only its\ndescendants match. `wait-for` re-resolves it every poll, including when it is\ninitially absent. Type names and literal whole ClassName values ignore case.\nThe only type aliases are `TextBox` → `Edit` and `TextBlock` → `Text`.\nSee [Scoped and typed queries](https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FWinAppCli\u002Fblob\u002Fmain\u002Fdocs\u002Fui-automation.md#scoped-and-typed-queries)\nfor the full type vocabulary, boundaries, and error behavior.\n\n### Discover and interact\n```powershell\n# See what's clickable, then screenshot for context\nwinapp ui inspect -a myapp --interactive; winapp ui screenshot -a myapp\n\n# Click and verify the page changed\nwinapp ui invoke btn-settings-a1b2 -a myapp; winapp ui wait-for pn-settingspage-c3d4 -a myapp --timeout 3000; winapp ui screenshot -a myapp\n\n# Fill a form and submit\nwinapp ui set-value txt-searchbox-e5f6 \"hello\" -a myapp; winapp ui invoke btn-submit-7a90 -a myapp; winapp ui screenshot -a myapp\n```\n\n### Find visible text and click it\n```powershell\n# Search by text — output shows invokable ancestor\nwinapp ui search \"Save changes\" -a myapp\n# Output:\n#   lbl-savechanges-a1b2 \"Save changes\" (120,40 80x20)\n#         ^ invoke via: btn-save-c3d4 \"Save\"\n\n# Invoke by text — auto-walks to parent Button\nwinapp ui invoke 'Save changes' -a myapp\n```\n\n### Navigate multi-page apps\n```powershell\n# Click nav item, wait for page, inspect what's available\nwinapp ui invoke itm-samples-3f2c -a myapp; winapp ui wait-for pn-samplespage-b4e7 -a myapp; winapp ui inspect -a myapp --interactive\n```\n\n### Choose an exact action in tests\n```powershell\nwinapp ui invoke SettingsCategory -a myapp --action select\nwinapp ui invoke AgreeCheckbox -a myapp --action toggle-on --json\nwinapp ui invoke Open -w \u003Cdialog-HWND> --type Button --action invoke\n```\n\nUse `--action` to avoid automatic pattern and ancestor fallback. Omit it for the\nexisting automatic behavior. With `--root`, `--type`, or `--class-name`, the\nfilters follow the same matching rules as read queries: exactly one element must\nmatch inside the selected app\u002Fwindow, or the command fails without acting, and\nthe ancestor fallback is skipped. See the\n[action reference](https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FwinappCli\u002Fblob\u002Fmain\u002Fdocs\u002Fui-automation.md#invoke)\nfor supported actions, scope, idempotent toggles, and failure recovery, and the\n[JSON envelope](references\u002Fui-json-envelope.md#ui-invoke---json) for action results.\n\n### Disambiguate duplicate elements\n```powershell\n# Text matches by substring, but an element named exactly the text wins\nwinapp ui invoke Submit -a myapp      # acts on Button \"Submit\", not Button \"Submit Order\"\n# When several elements share that name, the error shows slugs for each — pick the right one\nwinapp ui invoke Save -a myapp\n# → Selector matched 2 elements:\n#   [0] Button \"Save\" → btn-save-a1b2\n#   [1] Button \"Save\" → btn-save-c3d4\n# Use the slug: winapp ui invoke btn-save-c3d4 -a myapp\n```\n\n## Key concepts\n- **Selector brackets**: `inspect` and `search` output shows selectors in `[brackets]` — use the bracketed value with other `ui` commands. Selectors are either AutomationId (stable, developer-set) or generated slug (e.g., `btn-name-hash`).\n- **AutomationId selectors**: When an element has a unique AutomationId, it becomes the selector directly (e.g., `[MinimizeButton]`). These survive layout changes and localization — preferred for stable targeting.\n- **Slug selectors**: When no unique AutomationId exists, a generated slug is used (e.g., `[btn-close-a2b3]`). Format: `prefix-name-hash`. May go stale after UI changes.\n- **Plain text search**: `search` and `invoke` accept plain text — `search Minimize` finds elements with \"Minimize\" in their Name or AutomationId (substring, case-insensitive). No special syntax needed. Commands that act on one element prefer an exact AutomationId match, then the only element whose Name is exactly the text (ignoring case); `search` still lists every match.\n- **`--interactive` flag**: Filters to elements you can invoke, click, or set-value (including text documents) with auto-depth 8 — the fastest way to see what you can act on\n- **Invokable ancestor surfacing**: When a search result isn't invokable, the nearest invokable parent is shown with its selector\n- **`;` chaining**: Chain commands with `;` to run multiple operations in one call, reducing agent round-trips\n- **`-a` vs `-w`**: Use `-a` to find apps by name\u002Ftitle\u002FPID. Use `-w \u003CHWND>` for stable window targeting\n- **Element markers**: `[on]`\u002F`[off]` for toggles, `[collapsed]`\u002F`[expanded]`, `[scroll:v]`\u002F`[scroll:h]`\u002F`[scroll:vh]` for scrollable containers, `[offscreen]`, `[disabled]`, `value=\"...\"` for editable elements\n\n## Usage\n\n### Connect and discover\n```powershell\n# Core loop and examples: `winapp ui --help`. Connect and see interactive elements in one call:\nwinapp ui status -a myapp; winapp ui inspect -a myapp --interactive\n```\n\n### Inspect element tree\n```powershell\nwinapp ui inspect -a myapp --interactive      # elements you can invoke, click, or set-value; auto-depth 8\nwinapp ui inspect -a myapp --depth 5          # deeper tree at depth 5\nwinapp ui inspect txt-searchbox-e5f6 -a myapp  # subtree rooted at element\nwinapp ui inspect btn-settings-a1b2 -a myapp --ancestors  # walk up from element to root\nwinapp ui inspect -a myapp --hide-offscreen   # hide offscreen elements\n```\n\n### Find elements\n```powershell\nwinapp ui search Close -a myapp               # finds elements with \"Close\" in name or automationId\nwinapp ui search Button -a myapp              # finds elements with \"Button\" in name (also matches type names)\nwinapp ui search image -a myapp               # case-insensitive substring match\n```\n\n### Screenshot\n```powershell\n# App screenshot (may include owned windows in a labeled composite)\nwinapp ui screenshot -a myapp --output page.png\n\n# Crop to element; capture with popups visible\nwinapp ui screenshot txt-searchbox-e5f6 -a myapp --output search.png\nwinapp ui list-windows -a myapp # use the main window's HWND below\nwinapp ui screenshot -w \u003Chwnd> --capture-screen --output with-popups.png\n\n# Bring window to foreground first (matches what the user is currently seeing)\nwinapp ui screenshot -a myapp --focus --output focused.png\n```\n\nDefault capture includes owned windows even with an explicit main HWND; it produces one labeled composite, not separate image files. An element selector for an item in an open menu, flyout, tooltip, or teaching tip crops from that item's popup window, so you don't need `--capture-screen` for it. For scope and on-screen overlay placement, see [Screenshot](https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FWinAppCli\u002Fblob\u002Fmain\u002Fdocs\u002Fui-automation.md#screenshot). With `--on sandbox`, the reported screenshot path is the delivered host destination. In an app with WinUI DevTools attached, screenshots leave out its toolbar, markers, comment panel and inspector window.\n\n### Record video (H.264 MP4)\nRecord a window or element region to MP4. Prefer a positive `--duration-sec N` for\nagents and scripts; otherwise recording waits for a stop signal. npm helpers require\n`durationSec` (integer 1–86400). Their abort signal is forceful cancellation, not graceful stop.\n```powershell\n# Record a window for 10s at 15 fps\nwinapp ui record -a myapp --duration-sec 10 --fps 15 --output demo.mp4\n\n# Recommended agent evidence: MP4 plus timestamped JPEGs and an NDJSON index\nwinapp ui record -a myapp --frames --duration-sec 10 --fps 10 --output evidence.mp4 --json\n\n# Include overlays\u002Fpopups (captures from screen DC; may include occluding windows)\nwinapp ui record -a myapp --capture-screen --duration-sec 5 --output with-popups.mp4\n\n# Show the mouse pointer and click rings (for demos of click-driven flows)\nwinapp ui record -a myapp --cursor --duration-sec 10 --output demo.mp4\n\n# Programmatic stop: pipe a newline to stop and finalize the MP4 (for agent\u002Fscript callers)\n\"\" | winapp ui record -a myapp --json --output capture.mp4\n```\n- Default `--duration-sec 0` records until Ctrl+C, a newline, or EOF on redirected stdin.\n- `--frames` writes `\u003Coutput-name>.frames` with a manifest, NDJSON index, and changed JPEGs. It supports 1-30 fps and `--max-edge` 64-4096 (default 1280), with a 1 GiB cap. Use `elapsedMs` to bound transitions.\n- `--cursor` draws the pointer and a ring at each click; add `--no-click-highlight` to keep the pointer without rings. With `--frames`, each `frames.ndjson` line gains `cursor` (`x`, `y`, `visible`, `inFrame`) and `clicks` (`button`, `kind`, `elapsedMs`, `x`, `y`) in image pixels.\n- Existing recording outputs are rejected by default. Use a fresh path, or explicitly\n  request `--overwrite` to replace them after the new take finishes. Previous frame\n  directories are archived, not deleted. On partial failure, keep the reported evidence\n  and follow `recoveryHint`.\n- Default recording draws open menus, flyouts and tooltips over the window in place; no flag is needed. They're clipped to the window's bounds, and popups from other processes need `--capture-screen` (see [Menus and flyouts in recordings](https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FWinAppCli\u002Fblob\u002Fmain\u002Fdocs\u002Fui-automation.md#menus-and-flyouts-in-recordings)).\n- `--capture-screen` captures from the screen DC so overlays and popups are included; the window is brought to the foreground first. When WGC is unavailable and `--capture-screen` is not passed, the CLI returns an error — re-run with `--capture-screen` to consent to screen-DC capture. Because the screen DC captures whatever is genuinely in front, the target's foreground is **verified immediately before capture**; if activation was refused the command fails with `foreground_not_target` and writes nothing rather than returning an image of the wrong window.\n- Providing a selector that doesn't match any element fails immediately with `element_not_found` (rather than silently recording the whole window).\n- A selector for an item in an open menu, flyout, tooltip, or teaching tip records from that item's popup window, not the window behind it.\n- `--json` writes the final result to stdout and one JSON event per line to stderr.\n\n### Hover (for tooltips, flyouts, hover states)\n`--dwell-time \u003Cms>` sets how long to wait after hovering (default: 800, range: 0–10000).\n```powershell\nwinapp ui list-windows -a myapp # use the main window's HWND below, not the tooltip's\n\n# Hover to trigger tooltip, then capture it (default 800ms dwell)\nwinapp ui hover btn-info-a1b2 -a myapp; winapp ui screenshot -w \u003Chwnd> --capture-screen --output tooltip.png\n\n# Longer dwell for apps with slow tooltip timers\nwinapp ui hover btn-info-a1b2 -a myapp --dwell-time 1200; winapp ui screenshot -w \u003Chwnd> --capture-screen\n```\n\n### Click or hover a screen point\nWhen the press needs a point rather than an element's center (inside a WebView2 page, or one part of a large control), pass `--at x,y` with screen coordinates from `ui inspect` instead of a selector. `--at` can't be combined with a selector.\n```powershell\nwinapp ui click --at 1520,780 -a myapp            # add --right or --double as needed\nwinapp ui hover --at 1520,780 -a myapp\n```\n\n### Send keyboard input\nSynthesize keystrokes — the keyboard counterpart to `click`. Use for arrow\u002FTab\u002FEnter navigation, shortcuts, and per-keystroke typing (vs `set-value`'s atomic write). Tokens are whitespace-separated: named keys (`enter`, `down`, `tab`, `esc`, `f5`), modifier combos (`ctrl+shift+t`), literal text (`hello`), and raw virtual keys (`vk=0xNN`).\n```powershell\n# Keyboard navigation then commit\nwinapp ui send-keys \"down down enter\" -a myapp\n\n# Type the literal words \"down down enter\" instead of pressing those keys (text= escapes each token)\nwinapp ui send-keys \"text=down text=down text=enter\" -a myapp\n\n# Same intent, less typing: --verbatim types the whole argument literally (and keeps exact whitespace)\nwinapp ui send-keys \"down down enter\" -a myapp --verbatim\n\n# Shortcut: select all and delete\nwinapp ui send-keys \"ctrl+a delete\" -a myapp\n\n# Focus a field, then type text into it\nwinapp ui send-keys \"Hello world\" --target txt-name-a1b2 -a myapp\n\n# Transport: --via post-message (default, HWND-targeted, bypasses UIPI) or send-input (OS-wide)\nwinapp ui send-keys \"enter\" -a myapp --via send-input\n\n# Fire a global hotkey: win+... is refused by default (acts on the shell); opt in with --allow-system-keys\nwinapp ui send-keys \"win+shift+v\" -a myapp --via send-input --allow-system-keys\n\n# Screen-reader command: hold capslock or insert (Narrator+Ctrl+F12 toggles Narrator developer mode)\nwinapp ui send-keys \"ctrl+capslock+f12\" -a myapp --via send-input\n```\n- Screen-reader commands hold `capslock` or `insert` as a modifier (`ctrl+capslock+f12`) and require `--via send-input`; post-message errors because screen readers don't receive posted keys. If no screen reader is running, holding `capslock` turns Caps Lock on or off (the command warns); hold `insert` to avoid this.\n- A token that starts with a modifier but has an unknown middle segment (`ctrl+a+b`) is an error, not literal text; use `text=` or `--verbatim` to type it.\n- Default `post-message` is HWND-targeted and works across integrity levels, but can't fire `WH_KEYBOARD_LL` global hotkeys. It automatically retargets to the **focused child control** of the target window, so classic Win32\u002FWinForms child-window controls (e.g. an edit box) receive the input. **WinUI 3 \u002F UWP \u002F XAML controls are windowless and ignore posted `WM_CHAR`\u002F`WM_KEYDOWN`** — post-message can't deliver keys *or* text to them (the command emits a warning and still exits 0, since `PostMessage` can't confirm delivery). Use **`--via send-input`** for WinUI 3 \u002F UWP \u002F XAML apps.\n- A token that collides with a key\u002Fmodifier name (e.g. `enter`, `down`, `ctrl+a`) is pressed as that key. Prefix it with `text=` to type it as literal text instead — `text=enter` types the word \"enter\"; chain `text=` tokens to type a literal phrase like `text=down text=down text=enter`. Backslash escapes inside a `text=` value type whitespace the tokenizer would otherwise collapse: `\\s`→space, `\\t`→tab, `\\n`→newline, `\\r`→CR, `\\\\`→backslash (e.g. `text=a\\s\\sb` → \"a  b\"). When the *whole* argument is literal text, pass `--verbatim` instead of escaping each token: it types the entire keys argument as-is (no key\u002Fcombo\u002F`vk=`\u002F`text=` parsing) and preserves exact whitespace — `send-keys \"down down enter\" --verbatim` types the words. (`--verbatim` does not decode backslash escapes; use a `text=` token for control characters.)\n- `send-input` is fully real input but goes to the foreground window and is UIPI-blocked when injecting from elevated → AppContainer\u002FAppX. It **rejects system-reserved combos** (`win+l`, `alt+f4`, `ctrl+shift+esc`, `ctrl+alt+del`, `alt+tab`, …) because those act on the OS\u002Fshell, not just the target — pass **`--allow-system-keys`** to opt in (e.g. to fire a global hotkey such as PowerToys' `win+shift+v` or `win+r`), or use `--via post-message` (window-scoped) to send one straight to the window. **`win+l` and `ctrl+alt+del` stay blocked even with `--allow-system-keys`** — `win+l` locks the workstation via `LockWorkStation()` (unrecoverable from automation), and `ctrl+alt+del` is a Secure Attention Sequence (SAS) that Windows drops from injected input regardless of the flag, so it errors (`invalid_arguments`) instead of falsely reporting success. On a locked\u002Fsecure desktop `send-input` fails fast with `no_interactive_desktop`.\n- Per-keystroke events: named keys\u002Fcombos fire a real `KeyDown` on both transports. For literal typed text, `--via send-input` maps each char to its VK (+Shift) so each character fires a real `KeyDown` + OS-composed `WM_CHAR` (`TextChanged`) — use it when downstream logic keys off `KeyDown` (e.g. WinUI 3\u002FWPF `TextBox`); bring the target window to the foreground first. `--via post-message` posts a `WM_CHAR` per character to the focused child control (raises `TextChanged`, lands correct text into classic Win32 controls across integrity levels) but does not fire a per-character `KeyDown`, and — because WinUI 3 \u002F UWP \u002F XAML controls are windowless — does **not** reach them at all (named keys and text alike); use `--via send-input` there.\n- Long literal text on `--via send-input` is **auto-throttled**: the text is split into small character chunks injected one `SendInput` at a time with a brief pause between the chunks of that one run, so the target can drain its input queue and every character lands. A single unbroken burst overruns the queue and silently drops characters even though the command reports success. The pacing is scoped to a single long text run — short text, key names, and modifier combos (including sequences like `ctrl+a delete`) inject with no added delay, and the command emits an informational warning when a payload is large enough to be throttled. Because each paced chunk lands on whatever window is foreground, `send-input` re-verifies the target still owns the foreground before every continuation chunk and **aborts with `foreground_not_target`** if focus leaves the target mid-injection, so a focus change partway through can't spray the rest of the text into another window (a focus-changing chord such as `alt+tab` is exempt and is never treated as drift). For large bulk text, prefer `set-value` (atomic, no keystrokes or foreground needed) on controls that support it.\n\n### Drag (reorder, resize, sliders, drag-and-drop)\nPress the mouse button at one point, move to another, then release with `drag \u003Cfrom> \u003Cto>`, where each endpoint is an element selector (uses its center) or screen `x,y` coordinates from `ui inspect`. Uses `SendInput` with intermediate moves so apps see a realistic `WM_MOUSEMOVE` stream.\n```powershell\n# Reorder one item onto another (center → center)\nwinapp ui drag itm-card-9f8e itm-slot-2c1a -a myapp\n\n# Element center → screen coordinates (as reported by `ui inspect`)\nwinapp ui drag itm-card-9f8e 300,400 -a myapp\n\n# Raw screen coordinates → screen coordinates\nwinapp ui drag 120,200 480,200 -a myapp\n\n# Right-button drag\nwinapp ui drag itm-card-9f8e itm-trash-0001 -a myapp --right\n```\n- A selector drags from\u002Fto the element's center; `x,y` are screen coordinates in the same space `ui inspect`\u002F`search` report. Element endpoints are re-resolved just before the drag and fail with `target_moved` if still animating; on a locked\u002Fsecure desktop the drag fails with `no_interactive_desktop`.\n\n### Touch and pen input\nUse `winapp ui touch` for taps, long-press, swipes, and pinch\u002Fstretch, and `winapp ui pen` for pen taps and ink strokes. Both need a foregrounded target window on an unlocked, interactive desktop. Over Remote Desktop, exit 0 doesn't guarantee the input arrived; verify with a screenshot. See [touch and pen input](references\u002Ftouch-and-pen.md) for examples and options.\n\n### Read element state\n```powershell\n# Read text\u002Fvalue content (works for RichEditBox, TextBox, ComboBox, Slider, labels)\nwinapp ui get-value doc-texteditor-53ad -a notepad\nwinapp ui get-value SearchBox -a myapp\nwinapp ui get-value CmbTheme -a myapp              # reads ComboBox selected item via SelectionPattern\n\n# Check toggle\u002Fselection state, value, scroll position\nwinapp ui get-property chk-agreecheckbox-b2c3 -a myapp --property ToggleState\nwinapp ui get-property txt-textbox-a4b1 -a myapp --property Value\nwinapp ui get-property cmb-modellist-d5e6 -a myapp --property IsSelected\n\n# Read formatting across the whole text document (not the selection)\nwinapp ui get-property Document -a myapp --property FontWeight --json\n\n# See what has keyboard focus\nwinapp ui get-focused -a myapp\n```\n\nFor `get-focused`, `-a` includes windows in the selected process; `-w` restricts\nfocus to that exact window, excluding its owned popups. A control can belong to\nthe target through its parent window even when it omits its own process ID.\nSee `references\u002Fui-json-envelope.md` for focus no-match and query-error handling.\n\nTo check a blank or cleared field, use `winapp ui wait-for SearchBox -a myapp --value \"\"`.\nSee [empty-value behavior](https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fwinappcli\u002Fblob\u002Fmain\u002Fdocs\u002Fui-automation.md#get-value)\nfor JSON output and reading the accessibility label separately.\n\n`get-property` also accepts `FontName`, `FontSize`, `ForegroundColor`, `IsItalic`,\nand `StrikethroughStyle`. Omit `--property` to include all six formatting attributes.\nTreat `Mixed`, `NotSupported`, and `Unavailable` as distinct states, not formatting\nvalues. Names are case-sensitive; unknown names fail with `invalid_arguments`.\nSee the [formatting reference](https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fwinappcli\u002Fblob\u002Fmain\u002Fdocs\u002Fui-automation.md#whole-document-text-formatting)\nfor units and state meanings, and `references\u002Fui-json-envelope.md` for the JSON shape.\n\n### Set values\nTo prepare a control for keyboard input, use `winapp ui focus \u003Cselector> -a \u003Capp>`\n(keep `--on sandbox` when working in Sandbox). It activates the control's window\nand verifies both foreground and keyboard focus before success. It restores a\nminimized window first. If a command reports the target window is minimized (some\napps, such as Calculator, hide their UI until restored), run\n`winapp ui focus -a \u003Capp>` (no selector) to restore and activate it, then retry. Do not use a\nscreenshot as a focus workaround. If activation is refused, inspect for a blocking\ndialog and ask the user to activate the intended window; do not retry in a loop\nor switch to the local desktop. See the [focus reference](https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fwinappcli\u002Fblob\u002Fmain\u002Fdocs\u002Fui-automation.md#focus)\nfor failure codes and recovery.\n\n`set-value` writes programmatically (no keystrokes, no foreground) via a fallback chain: ValuePattern → RangeValuePattern (numeric) → LegacyIAccessible `put_accValue` for TextPattern-only edit controls.\n```powershell\nwinapp ui set-value txt-searchbox-e5f6 \"hello\" -a myapp        # TextBox\u002FComboBox via ValuePattern\nwinapp ui set-value sld-volume-b2c3 75 -a myapp                # Slider via RangeValuePattern\nwinapp ui set-value doc-compose-9f3a \"hello\" -a myapp          # RichEdit\u002Fcompose box via LegacyIAccessible\n```\n- The LegacyIAccessible fallback reaches rich-edit\u002Fcompose controls that expose no ValuePattern, as long as their accessibility implements `put_accValue` (native Win32 rich-edit and Chromium\u002FElectron\u002FWebView2 compose boxes typically do).\n- **WinUI 3 `RichEditBox` and WPF `RichTextBox` don't support programmatic value-setting** — by design they're read-only to UI Automation's value APIs (Text pattern, no settable Value pattern). `set-value` fails on them with a clear error — use `send-keys` (needs an unlocked, foregrounded desktop) to type into those instead. Note `get-value` can still *read* them via TextPattern.\n\n### Scroll containers\n```powershell\n# Find scrollable containers — look for [scroll:v] (vertical) or [scroll:h] (horizontal)\nwinapp ui search scroll -a myapp\n# Output:\n#   pn-scrollview-bfef Pane \"scrollView\" [scroll:v] (2127,296 1191x965)\n#   pn-scrollviewer-bfb1 Pane \"scrollViewer\" [scroll:h] (2127,296 1191x216)\n\n# Scroll vertically\nwinapp ui scroll pn-scrollview-bfef --direction down -a myapp\n\n# Scroll to top\u002Fbottom\nwinapp ui scroll pn-scrollview-bfef --to bottom -a myapp\n\n# Scroll and then inspect for newly visible elements\nwinapp ui scroll pn-scrollview-bfef --direction down -a myapp; winapp ui search TargetItem -a myapp\n\n# Synthesize real mouse-wheel input over the element (1 = one notch up, -1 = down) — tests wheel handlers (zoom, custom scroll)\nwinapp ui scroll img-map-a1b2 --wheel -1 -a myapp\n\n# Horizontal (tilt) wheel: 1 = one notch right, -1 = left — pans timelines and other horizontal-wheel handlers\nwinapp ui scroll pn-timeline-c3d4 --wheel-horizontal 3 -a myapp\n```\n\n### Wait for UI state\n```powershell\nwinapp ui wait-for btn-submit-a1b2 -a myapp --timeout 5000\nwinapp ui wait-for itm-status-c3d4 -a myapp --value \"Complete\" --timeout 5000\n```\n\n## Tips\n- Use `--interactive` with `inspect` as your first command — it shows only what you can act on\n- Chain commands with `;` to reduce round-trips (see note below on why not `&&`)\n- Use slugs from output to target specific elements — they're hash-validated and shell-safe\n- Use plain text search to find elements: `search Minimize`, `invoke Submit`\n- When text matches several elements, the only element named exactly that text wins; if several still match, the error shows slugs for each — pick the right one\n- Use `get-property --property ToggleState` to verify checkbox\u002Ftoggle state after invoke\n- `scroll` auto-finds the nearest scrollable parent\n- To capture one item in an open menu, flyout, tooltip, or teaching tip, pass its selector to `screenshot` or `record`; it is captured from its popup window\n- Follow [Screenshot](#screenshot) to select a window with `-w \u003Chwnd> --capture-screen` when you need popups in place over the window, or overlays the app doesn't own\n- Follow [Hover](#hover-for-tooltips-flyouts-hover-states) to capture tooltips and hover-triggered UI in place\n- Use `--focus` to foreground the target window before capture without switching to screen-DC capture (default capture path uses Windows.Graphics.Capture and works while occluded)\n- Use `--hide-disabled` and `--hide-offscreen` to reduce noise\n\n### Why `;` instead of `&&`\nUse `;` (not `&&`) to chain commands. PowerShell's `&&` operator can freeze when a native CLI writes to stderr or uses ANSI escape sequences — this causes a pipeline deadlock. `;` runs each command unconditionally and avoids this issue. This is also better for agent workflows: you usually want the screenshot to run even if the invoke had a non-zero exit (to see what went wrong).\n\n### File dialog workaround\nFile open\u002Fsave dialogs are standard Windows dialogs with UIA support. Interact with them using existing commands:\n```powershell\n# 1. Trigger the dialog (e.g., click \"Open File\" button)\nwinapp ui invoke btn-openfilebtn-a2b3 -a myapp\n\n# 2. Find the dialog window\nwinapp ui list-windows -a myapp\n# → Shows the main window + the dialog HWND\n# Note: untitled zero-size windows are hidden by default; use --show-hidden to include them\n\n# 3. Target the dialog, type the file path, and confirm\nwinapp ui set-value txt-1148-c4d5 \"C:\\path\\to\\file.png\" -w \u003Cdialog-hwnd>\nwinapp ui invoke btn-open-e6f7 -w \u003Cdialog-hwnd>\n```\nNote: The filename input in standard file dialogs typically has AutomationId `1148`. Use `inspect -w \u003Cdialog-hwnd> --interactive` to discover the actual slugs.\n\n## JSON output envelopes\n\nUse each element's `selector` as its handle. Elements report `type` (not `controlType`) and `x`, `y`, `width`, and `height` in physical screen pixels.\nFor each `--json` shape, with examples and what changed in v0.3.1 and v0.6.3, see [JSON envelopes](references\u002Fui-json-envelope.md).\n\n## Automating in Windows Sandbox\n\n```powershell\nwinapp run . --on sandbox --detach\nwinapp ui inspect --on sandbox -a MyApp\nwinapp ui screenshot --on sandbox -a MyApp -o .\\result.png\n```\n\nUse `--detach` before follow-up UI commands, and retain `--on sandbox` with guest PIDs\nor window handles. Inject the same `WINAPP_UI_WORKFLOW_ID` into cooperating guest calls;\nfinish with `winapp ui yield --on sandbox` after all of them complete.\n\nUse `winapp-sandbox` for setup consent, connected-client requirements, brief focus\nchanges during setup\u002Freconnect, and capture recovery. App screenshots and recordings,\nincluding default filenames and `--frames` directories, return to the host.\n\n## Related skills\n- `winapp-sandbox` for running and automating apps in an isolated Windows Sandbox\n- `winapp-setup` for adding Windows SDK to your project\n- `winapp-package` for packaging apps as MSIX\n\n## Troubleshooting\n| Error | Cause | Solution |\n|---|---|---|\n| \"No running app found\" | Wrong name or app not running | Try process name, window title, or PID |\n| \"Multiple windows match\" | Several windows match `-a` | Use `-w \u003CHWND>` from the listed options |\n| \"Selector matched N elements\" | Text query matches multiple elements | Use a slug from the suggestions shown in the error, or from `inspect` output |\n| \"Element may have changed\" | Slug hash doesn't match current element | Re-run `inspect` to get fresh slugs |\n| \"does not support any invoke pattern\" | Element can't be invoked | The error shows the invokable ancestor slug if one exists — use that |\n| \"No UIA window found\" | UIA can't see the window | Use `list-windows` to find HWND, then `-w` |\n| Popup not in screenshot | Default capture path doesn't include unowned overlays | For one item in an open menu or flyout, pass its selector. To show popups in place or capture unowned overlays, follow [Screenshot](#screenshot) to select a window with `-w \u003Chwnd> --capture-screen` |\n| `foreground_not_target` from `--capture-screen` | Windows refused the activation (focus-stealing prevention, UAC prompt, another window activating itself), so a screen capture would have recorded the wrong window | Click the target window, close the window that stole focus, then retry — or drop `--capture-screen` to capture the window directly |\n| `element_not_found` during record | Selector given but element not in tree | Re-run `inspect` or `search` to get a fresh selector |\n| `ambiguous_selector` during record | Plain-text selector matched multiple elements | Use a slug from the suggestions in the error message, or from `inspect` output |\n| WGC unavailable during record | WGC capture init failed; no silent fallback | Check GPU\u002Fdriver; use `--capture-screen` to explicitly request screen DC capture |\n\n## CLI reference\n\nRun `winapp \u003Ccommand> --help` for current command options, or `winapp --cli-schema` for the complete machine-readable command schema.\n","**If you can't run `winapp` yourself** (no shell, or the command is denied), give the user the exact `winapp` command(s) for their project instead of only describing the steps.\n\n## When to use\n- Inspecting a running Windows app's UI from the command line\n- AI agents interacting with Windows applications (clicking buttons, reading text, taking screenshots)\n- Verifying UI state during development or testing\n- Automating UI workflows without Playwright or Selenium\n- Debugging WinUI 3, WPF, WinForms, Win32, or Electron app UIs by what the user sees and can operate\n- Not for a WinUI 3 app's XAML internals (why a value or binding resolved the way it did, which XAML line made an element, live property edits, UI review comments): use `winui-devtools`\n\n## Prerequisites\nFor WinUI 3 XAML source\u002Ftree, bindings or dependency-property diagnosis and edits,\nuse the `winui-devtools` skill and `winapp devtools`. It requires an attached\ntarget or explicit authorization to inject with `--attach`; a PID alone is not\nconsent. An AutomationId works as a selector in both tools; generated slugs do\nnot transfer to DevTools. Continue using `winapp ui`\nfor cross-framework actions, screenshots, waits and accessibility.\n\nTo measure WinUI work while driving a scenario, use the\n`winapp-performance` skill to bracket UI actions with capture markers.\n\n- For UIA mode (any app): No setup needed — works with any running Windows app\n- For input-injecting verbs (`click`, `hover`, `drag`, `touch`, `pen`, `scroll --wheel`\u002F`--wheel-horizontal`, `send-keys --via send-input`): an **unlocked, interactive desktop** with the target window foregroundable. On a locked\u002Fsecure desktop they fail fast with `no_interactive_desktop`. The UIA-pattern verbs (`inspect`, `search`, `get-*`, `wait-for`, `set-value`, `invoke`, `scroll --direction\u002F--to`) are headless\u002Flocked-session friendly — prefer them in CI.\n- `screenshot` is **not** in that group: it always takes an exclusive turn, so it queues behind other UI workflows, and capture can need a usable interactive desktop — the engine restores the target if it is minimized, and falls back to foregrounding it when frame capture is unavailable or `--capture-screen` is used.\n- `--capture-screen` needs **exactly one window**. `-w \u003Chwnd>` gives it one: that window's screen region, including anything visibly on top of it. If `-a` matches several top-level or owned windows the command fails with `invalid_arguments` before capturing; run `winapp ui list-windows -a \u003Capp>` and retry with `-w \u003Chwnd>`.\n- **If other UI workflows may run at the same time**, set one workflow id per logical workflow (see below). Nothing breaks without it, but your commands will not be recognized as belonging together.\n\n## Coordinating with other UI workflows\n\nWindows has one foreground window, one keyboard focus, one cursor, and one input stream. `winapp ui`\ntherefore makes desktop-driving commands take **cooperative turns** so concurrent workflows cannot\nsteal each other's focus or dismiss each other's menus. That is always on. Read-only commands never\nwait.\n\nKeeping the desktop *across* commands is opt-in — without an id, each command is a one-shot that\nreleases the desktop the moment it finishes:\n\n```powershell\n# Set once per logical UI workflow — same value for cooperating calls, different values for\n# independent workflows (even from the same agent).\n$env:WINAPP_UI_WORKFLOW_ID = [guid]::NewGuid().ToString()\n```\n\nRules that matter when driving this from an agent:\n\n- **Each tool call usually gets a fresh shell**, and there is no process-ancestry fallback, so\n  commands are grouped ONLY by the id you inject. Without it every call is its own workflow.\n- **A workflow with an id keeps its turn for four seconds** after its last command. That covers\n  back-to-back commands in one script; it deliberately expires while you are reasoning. Treat it as\n  a fallback for when you cannot say you are done — not as the way to finish.\n- **Run `winapp ui yield` when you finish a known sequence.** It hands the desktop over immediately\n  instead of making a waiting workflow sit out a four-second grace nobody needs. Yielding twice, or\n  after the grace lapsed, is a harmless success.\n- **After a reasoning gap, replay your setup.** Another workflow may have used the desktop, so\n  reopen the menu \u002F re-navigate, re-resolve the element, then act. Do not assume transient UI\n  survived.\n- **Prefer one tight script over many round trips** for a known sequence: `winapp ui invoke View -w\n  $hwnd; winapp ui search \"Status bar\" -w $hwnd; winapp ui click \"Status bar\" -w $hwnd; winapp ui yield`.\n- **`record` shares the turn with its own workflow**, so same-workflow clicks and typing are captured\n  while it runs — but only if both commands carry the same id. A `record` with no id blocks everyone\n  else for its whole duration.\n- **Ordering is owner affinity, then FIFO.** An active workflow may keep issuing commands ahead of\n  others already waiting; once it yields or its grace expires, waiters are served in arrival order.\n- **Waiting is indefinite and cancellable.** After one second a notice on stderr says what holds the\n  desktop and for how long (silent under `--json` and `--quiet`); Ctrl+C exits `130` with error code\n  `cancelled` and the command never ran.\n- **There is no hard cap** — a long script, unbounded recording, or failure loop can block other\n  mutating workflows until it finishes or is stopped.\n\nCommands that never wait: `status`, `list-windows`, `inspect`, `search`, `get-*`, `wait-for`.\nCommands that wait for the turn but never take the desktop (headless\u002Flocked-session friendly):\n`set-value`, `scroll-into-view`, `scroll --direction`\u002F`--to`, `record`. They mutate the app, so they\nqueue behind another workflow. Inside your own workflow they overlap with other shared work — that\nis how `record` captures the `set-value` calls it is recording — but they still wait behind an\nearlier `DesktopExclusive` command of your own workflow, so a `click` followed by a `set-value` runs\nin the order you wrote it.\nCommands that take the desktop exclusively: `invoke`, `click`, `drag`, `hover`, `scroll --wheel`\u002F`--wheel-horizontal`,\n`touch`, `pen`, `focus`, `send-keys`, `screenshot`.\n\n```powershell\n# Finish a workflow deliberately rather than leaving the desktop reserved for four more seconds.\nwinapp ui yield\n```\n\n## Common patterns\n\n### Read within a specific container\n\n```powershell\nwinapp ui search \"Welcome to MyApp\" -a myapp --root MailRow --type Text --class-name TextBlock\nwinapp ui get-value Subject -a myapp --root MailRow --type TextBox\nwinapp ui wait-for Subject -a myapp --root MailRow --type Edit --value Ready --timeout 10000\nwinapp ui search --class-name CalendarSurface -a myapp   # no text selector needed\n```\n\nUse `--root`, `--type`, and `--class-name` together or separately on `search`,\n`get-property`, `get-value`, `wait-for`, and the commands that act on one\nselected element (`invoke`, `set-value`, `click`, `focus`, and so on; not `send-keys --target`).\n`--type` and `--class-name` work without a selector; commands other than `search` then need\nexactly one match, and an ambiguous match lists the first five with their slugs. `--root` alone is not a query. For `set-value`, pass `\"\"` as the selector.\nFor `click`, `hover`, `touch`, and `pen`, filters can't be combined with `--at` or `--path`. The root must be unique; only its\ndescendants match. `wait-for` re-resolves it every poll, including when it is\ninitially absent. Type names and literal whole ClassName values ignore case.\nThe only type aliases are `TextBox` → `Edit` and `TextBlock` → `Text`.\nSee [Scoped and typed queries](https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FWinAppCli\u002Fblob\u002Fmain\u002Fdocs\u002Fui-automation.md#scoped-and-typed-queries)\nfor the full type vocabulary, boundaries, and error behavior.\n\n### Discover and interact\n```powershell\n# See what's clickable, then screenshot for context\nwinapp ui inspect -a myapp --interactive; winapp ui screenshot -a myapp\n\n# Click and verify the page changed\nwinapp ui invoke btn-settings-a1b2 -a myapp; winapp ui wait-for pn-settingspage-c3d4 -a myapp --timeout 3000; winapp ui screenshot -a myapp\n\n# Fill a form and submit\nwinapp ui set-value txt-searchbox-e5f6 \"hello\" -a myapp; winapp ui invoke btn-submit-7a90 -a myapp; winapp ui screenshot -a myapp\n```\n\n### Find visible text and click it\n```powershell\n# Search by text — output shows invokable ancestor\nwinapp ui search \"Save changes\" -a myapp\n# Output:\n#   lbl-savechanges-a1b2 \"Save changes\" (120,40 80x20)\n#         ^ invoke via: btn-save-c3d4 \"Save\"\n\n# Invoke by text — auto-walks to parent Button\nwinapp ui invoke 'Save changes' -a myapp\n```\n\n### Navigate multi-page apps\n```powershell\n# Click nav item, wait for page, inspect what's available\nwinapp ui invoke itm-samples-3f2c -a myapp; winapp ui wait-for pn-samplespage-b4e7 -a myapp; winapp ui inspect -a myapp --interactive\n```\n\n### Choose an exact action in tests\n```powershell\nwinapp ui invoke SettingsCategory -a myapp --action select\nwinapp ui invoke AgreeCheckbox -a myapp --action toggle-on --json\nwinapp ui invoke Open -w \u003Cdialog-HWND> --type Button --action invoke\n```\n\nUse `--action` to avoid automatic pattern and ancestor fallback. Omit it for the\nexisting automatic behavior. With `--root`, `--type`, or `--class-name`, the\nfilters follow the same matching rules as read queries: exactly one element must\nmatch inside the selected app\u002Fwindow, or the command fails without acting, and\nthe ancestor fallback is skipped. See the\n[action reference](https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FwinappCli\u002Fblob\u002Fmain\u002Fdocs\u002Fui-automation.md#invoke)\nfor supported actions, scope, idempotent toggles, and failure recovery, and the\n[JSON envelope](references\u002Fui-json-envelope.md#ui-invoke---json) for action results.\n\n### Disambiguate duplicate elements\n```powershell\n# Text matches by substring, but an element named exactly the text wins\nwinapp ui invoke Submit -a myapp      # acts on Button \"Submit\", not Button \"Submit Order\"\n# When several elements share that name, the error shows slugs for each — pick the right one\nwinapp ui invoke Save -a myapp\n# → Selector matched 2 elements:\n#   [0] Button \"Save\" → btn-save-a1b2\n#   [1] Button \"Save\" → btn-save-c3d4\n# Use the slug: winapp ui invoke btn-save-c3d4 -a myapp\n```\n\n## Key concepts\n- **Selector brackets**: `inspect` and `search` output shows selectors in `[brackets]` — use the bracketed value with other `ui` commands. Selectors are either AutomationId (stable, developer-set) or generated slug (e.g., `btn-name-hash`).\n- **AutomationId selectors**: When an element has a unique AutomationId, it becomes the selector directly (e.g., `[MinimizeButton]`). These survive layout changes and localization — preferred for stable targeting.\n- **Slug selectors**: When no unique AutomationId exists, a generated slug is used (e.g., `[btn-close-a2b3]`). Format: `prefix-name-hash`. May go stale after UI changes.\n- **Plain text search**: `search` and `invoke` accept plain text — `search Minimize` finds elements with \"Minimize\" in their Name or AutomationId (substring, case-insensitive). No special syntax needed. Commands that act on one element prefer an exact AutomationId match, then the only element whose Name is exactly the text (ignoring case); `search` still lists every match.\n- **`--interactive` flag**: Filters to elements you can invoke, click, or set-value (including text documents) with auto-depth 8 — the fastest way to see what you can act on\n- **Invokable ancestor surfacing**: When a search result isn't invokable, the nearest invokable parent is shown with its selector\n- **`;` chaining**: Chain commands with `;` to run multiple operations in one call, reducing agent round-trips\n- **`-a` vs `-w`**: Use `-a` to find apps by name\u002Ftitle\u002FPID. Use `-w \u003CHWND>` for stable window targeting\n- **Element markers**: `[on]`\u002F`[off]` for toggles, `[collapsed]`\u002F`[expanded]`, `[scroll:v]`\u002F`[scroll:h]`\u002F`[scroll:vh]` for scrollable containers, `[offscreen]`, `[disabled]`, `value=\"...\"` for editable elements\n\n## Usage\n\n### Connect and discover\n```powershell\n# Core loop and examples: `winapp ui --help`. Connect and see interactive elements in one call:\nwinapp ui status -a myapp; winapp ui inspect -a myapp --interactive\n```\n\n### Inspect element tree\n```powershell\nwinapp ui inspect -a myapp --interactive      # elements you can invoke, click, or set-value; auto-depth 8\nwinapp ui inspect -a myapp --depth 5          # deeper tree at depth 5\nwinapp ui inspect txt-searchbox-e5f6 -a myapp  # subtree rooted at element\nwinapp ui inspect btn-settings-a1b2 -a myapp --ancestors  # walk up from element to root\nwinapp ui inspect -a myapp --hide-offscreen   # hide offscreen elements\n```\n\n### Find elements\n```powershell\nwinapp ui search Close -a myapp               # finds elements with \"Close\" in name or automationId\nwinapp ui search Button -a myapp              # finds elements with \"Button\" in name (also matches type names)\nwinapp ui search image -a myapp               # case-insensitive substring match\n```\n\n### Screenshot\n```powershell\n# App screenshot (may include owned windows in a labeled composite)\nwinapp ui screenshot -a myapp --output page.png\n\n# Crop to element; capture with popups visible\nwinapp ui screenshot txt-searchbox-e5f6 -a myapp --output search.png\nwinapp ui list-windows -a myapp # use the main window's HWND below\nwinapp ui screenshot -w \u003Chwnd> --capture-screen --output with-popups.png\n\n# Bring window to foreground first (matches what the user is currently seeing)\nwinapp ui screenshot -a myapp --focus --output focused.png\n```\n\nDefault capture includes owned windows even with an explicit main HWND; it produces one labeled composite, not separate image files. An element selector for an item in an open menu, flyout, tooltip, or teaching tip crops from that item's popup window, so you don't need `--capture-screen` for it. For scope and on-screen overlay placement, see [Screenshot](https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FWinAppCli\u002Fblob\u002Fmain\u002Fdocs\u002Fui-automation.md#screenshot). With `--on sandbox`, the reported screenshot path is the delivered host destination. In an app with WinUI DevTools attached, screenshots leave out its toolbar, markers, comment panel and inspector window.\n\n### Record video (H.264 MP4)\nRecord a window or element region to MP4. Prefer a positive `--duration-sec N` for\nagents and scripts; otherwise recording waits for a stop signal. npm helpers require\n`durationSec` (integer 1–86400). Their abort signal is forceful cancellation, not graceful stop.\n```powershell\n# Record a window for 10s at 15 fps\nwinapp ui record -a myapp --duration-sec 10 --fps 15 --output demo.mp4\n\n# Recommended agent evidence: MP4 plus timestamped JPEGs and an NDJSON index\nwinapp ui record -a myapp --frames --duration-sec 10 --fps 10 --output evidence.mp4 --json\n\n# Include overlays\u002Fpopups (captures from screen DC; may include occluding windows)\nwinapp ui record -a myapp --capture-screen --duration-sec 5 --output with-popups.mp4\n\n# Show the mouse pointer and click rings (for demos of click-driven flows)\nwinapp ui record -a myapp --cursor --duration-sec 10 --output demo.mp4\n\n# Programmatic stop: pipe a newline to stop and finalize the MP4 (for agent\u002Fscript callers)\n\"\" | winapp ui record -a myapp --json --output capture.mp4\n```\n- Default `--duration-sec 0` records until Ctrl+C, a newline, or EOF on redirected stdin.\n- `--frames` writes `\u003Coutput-name>.frames` with a manifest, NDJSON index, and changed JPEGs. It supports 1-30 fps and `--max-edge` 64-4096 (default 1280), with a 1 GiB cap. Use `elapsedMs` to bound transitions.\n- `--cursor` draws the pointer and a ring at each click; add `--no-click-highlight` to keep the pointer without rings. With `--frames`, each `frames.ndjson` line gains `cursor` (`x`, `y`, `visible`, `inFrame`) and `clicks` (`button`, `kind`, `elapsedMs`, `x`, `y`) in image pixels.\n- Existing recording outputs are rejected by default. Use a fresh path, or explicitly\n  request `--overwrite` to replace them after the new take finishes. Previous frame\n  directories are archived, not deleted. On partial failure, keep the reported evidence\n  and follow `recoveryHint`.\n- Default recording draws open menus, flyouts and tooltips over the window in place; no flag is needed. They're clipped to the window's bounds, and popups from other processes need `--capture-screen` (see [Menus and flyouts in recordings](https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FWinAppCli\u002Fblob\u002Fmain\u002Fdocs\u002Fui-automation.md#menus-and-flyouts-in-recordings)).\n- `--capture-screen` captures from the screen DC so overlays and popups are included; the window is brought to the foreground first. When WGC is unavailable and `--capture-screen` is not passed, the CLI returns an error — re-run with `--capture-screen` to consent to screen-DC capture. Because the screen DC captures whatever is genuinely in front, the target's foreground is **verified immediately before capture**; if activation was refused the command fails with `foreground_not_target` and writes nothing rather than returning an image of the wrong window.\n- Providing a selector that doesn't match any element fails immediately with `element_not_found` (rather than silently recording the whole window).\n- A selector for an item in an open menu, flyout, tooltip, or teaching tip records from that item's popup window, not the window behind it.\n- `--json` writes the final result to stdout and one JSON event per line to stderr.\n\n### Hover (for tooltips, flyouts, hover states)\n`--dwell-time \u003Cms>` sets how long to wait after hovering (default: 800, range: 0–10000).\n```powershell\nwinapp ui list-windows -a myapp # use the main window's HWND below, not the tooltip's\n\n# Hover to trigger tooltip, then capture it (default 800ms dwell)\nwinapp ui hover btn-info-a1b2 -a myapp; winapp ui screenshot -w \u003Chwnd> --capture-screen --output tooltip.png\n\n# Longer dwell for apps with slow tooltip timers\nwinapp ui hover btn-info-a1b2 -a myapp --dwell-time 1200; winapp ui screenshot -w \u003Chwnd> --capture-screen\n```\n\n### Click or hover a screen point\nWhen the press needs a point rather than an element's center (inside a WebView2 page, or one part of a large control), pass `--at x,y` with screen coordinates from `ui inspect` instead of a selector. `--at` can't be combined with a selector.\n```powershell\nwinapp ui click --at 1520,780 -a myapp            # add --right or --double as needed\nwinapp ui hover --at 1520,780 -a myapp\n```\n\n### Send keyboard input\nSynthesize keystrokes — the keyboard counterpart to `click`. Use for arrow\u002FTab\u002FEnter navigation, shortcuts, and per-keystroke typing (vs `set-value`'s atomic write). Tokens are whitespace-separated: named keys (`enter`, `down`, `tab`, `esc`, `f5`), modifier combos (`ctrl+shift+t`), literal text (`hello`), and raw virtual keys (`vk=0xNN`).\n```powershell\n# Keyboard navigation then commit\nwinapp ui send-keys \"down down enter\" -a myapp\n\n# Type the literal words \"down down enter\" instead of pressing those keys (text= escapes each token)\nwinapp ui send-keys \"text=down text=down text=enter\" -a myapp\n\n# Same intent, less typing: --verbatim types the whole argument literally (and keeps exact whitespace)\nwinapp ui send-keys \"down down enter\" -a myapp --verbatim\n\n# Shortcut: select all and delete\nwinapp ui send-keys \"ctrl+a delete\" -a myapp\n\n# Focus a field, then type text into it\nwinapp ui send-keys \"Hello world\" --target txt-name-a1b2 -a myapp\n\n# Transport: --via post-message (default, HWND-targeted, bypasses UIPI) or send-input (OS-wide)\nwinapp ui send-keys \"enter\" -a myapp --via send-input\n\n# Fire a global hotkey: win+... is refused by default (acts on the shell); opt in with --allow-system-keys\nwinapp ui send-keys \"win+shift+v\" -a myapp --via send-input --allow-system-keys\n\n# Screen-reader command: hold capslock or insert (Narrator+Ctrl+F12 toggles Narrator developer mode)\nwinapp ui send-keys \"ctrl+capslock+f12\" -a myapp --via send-input\n```\n- Screen-reader commands hold `capslock` or `insert` as a modifier (`ctrl+capslock+f12`) and require `--via send-input`; post-message errors because screen readers don't receive posted keys. If no screen reader is running, holding `capslock` turns Caps Lock on or off (the command warns); hold `insert` to avoid this.\n- A token that starts with a modifier but has an unknown middle segment (`ctrl+a+b`) is an error, not literal text; use `text=` or `--verbatim` to type it.\n- Default `post-message` is HWND-targeted and works across integrity levels, but can't fire `WH_KEYBOARD_LL` global hotkeys. It automatically retargets to the **focused child control** of the target window, so classic Win32\u002FWinForms child-window controls (e.g. an edit box) receive the input. **WinUI 3 \u002F UWP \u002F XAML controls are windowless and ignore posted `WM_CHAR`\u002F`WM_KEYDOWN`** — post-message can't deliver keys *or* text to them (the command emits a warning and still exits 0, since `PostMessage` can't confirm delivery). Use **`--via send-input`** for WinUI 3 \u002F UWP \u002F XAML apps.\n- A token that collides with a key\u002Fmodifier name (e.g. `enter`, `down`, `ctrl+a`) is pressed as that key. Prefix it with `text=` to type it as literal text instead — `text=enter` types the word \"enter\"; chain `text=` tokens to type a literal phrase like `text=down text=down text=enter`. Backslash escapes inside a `text=` value type whitespace the tokenizer would otherwise collapse: `\\s`→space, `\\t`→tab, `\\n`→newline, `\\r`→CR, `\\\\`→backslash (e.g. `text=a\\s\\sb` → \"a  b\"). When the *whole* argument is literal text, pass `--verbatim` instead of escaping each token: it types the entire keys argument as-is (no key\u002Fcombo\u002F`vk=`\u002F`text=` parsing) and preserves exact whitespace — `send-keys \"down down enter\" --verbatim` types the words. (`--verbatim` does not decode backslash escapes; use a `text=` token for control characters.)\n- `send-input` is fully real input but goes to the foreground window and is UIPI-blocked when injecting from elevated → AppContainer\u002FAppX. It **rejects system-reserved combos** (`win+l`, `alt+f4`, `ctrl+shift+esc`, `ctrl+alt+del`, `alt+tab`, …) because those act on the OS\u002Fshell, not just the target — pass **`--allow-system-keys`** to opt in (e.g. to fire a global hotkey such as PowerToys' `win+shift+v` or `win+r`), or use `--via post-message` (window-scoped) to send one straight to the window. **`win+l` and `ctrl+alt+del` stay blocked even with `--allow-system-keys`** — `win+l` locks the workstation via `LockWorkStation()` (unrecoverable from automation), and `ctrl+alt+del` is a Secure Attention Sequence (SAS) that Windows drops from injected input regardless of the flag, so it errors (`invalid_arguments`) instead of falsely reporting success. On a locked\u002Fsecure desktop `send-input` fails fast with `no_interactive_desktop`.\n- Per-keystroke events: named keys\u002Fcombos fire a real `KeyDown` on both transports. For literal typed text, `--via send-input` maps each char to its VK (+Shift) so each character fires a real `KeyDown` + OS-composed `WM_CHAR` (`TextChanged`) — use it when downstream logic keys off `KeyDown` (e.g. WinUI 3\u002FWPF `TextBox`); bring the target window to the foreground first. `--via post-message` posts a `WM_CHAR` per character to the focused child control (raises `TextChanged`, lands correct text into classic Win32 controls across integrity levels) but does not fire a per-character `KeyDown`, and — because WinUI 3 \u002F UWP \u002F XAML controls are windowless — does **not** reach them at all (named keys and text alike); use `--via send-input` there.\n- Long literal text on `--via send-input` is **auto-throttled**: the text is split into small character chunks injected one `SendInput` at a time with a brief pause between the chunks of that one run, so the target can drain its input queue and every character lands. A single unbroken burst overruns the queue and silently drops characters even though the command reports success. The pacing is scoped to a single long text run — short text, key names, and modifier combos (including sequences like `ctrl+a delete`) inject with no added delay, and the command emits an informational warning when a payload is large enough to be throttled. Because each paced chunk lands on whatever window is foreground, `send-input` re-verifies the target still owns the foreground before every continuation chunk and **aborts with `foreground_not_target`** if focus leaves the target mid-injection, so a focus change partway through can't spray the rest of the text into another window (a focus-changing chord such as `alt+tab` is exempt and is never treated as drift). For large bulk text, prefer `set-value` (atomic, no keystrokes or foreground needed) on controls that support it.\n\n### Drag (reorder, resize, sliders, drag-and-drop)\nPress the mouse button at one point, move to another, then release with `drag \u003Cfrom> \u003Cto>`, where each endpoint is an element selector (uses its center) or screen `x,y` coordinates from `ui inspect`. Uses `SendInput` with intermediate moves so apps see a realistic `WM_MOUSEMOVE` stream.\n```powershell\n# Reorder one item onto another (center → center)\nwinapp ui drag itm-card-9f8e itm-slot-2c1a -a myapp\n\n# Element center → screen coordinates (as reported by `ui inspect`)\nwinapp ui drag itm-card-9f8e 300,400 -a myapp\n\n# Raw screen coordinates → screen coordinates\nwinapp ui drag 120,200 480,200 -a myapp\n\n# Right-button drag\nwinapp ui drag itm-card-9f8e itm-trash-0001 -a myapp --right\n```\n- A selector drags from\u002Fto the element's center; `x,y` are screen coordinates in the same space `ui inspect`\u002F`search` report. Element endpoints are re-resolved just before the drag and fail with `target_moved` if still animating; on a locked\u002Fsecure desktop the drag fails with `no_interactive_desktop`.\n\n### Touch and pen input\nUse `winapp ui touch` for taps, long-press, swipes, and pinch\u002Fstretch, and `winapp ui pen` for pen taps and ink strokes. Both need a foregrounded target window on an unlocked, interactive desktop. Over Remote Desktop, exit 0 doesn't guarantee the input arrived; verify with a screenshot. See [touch and pen input](references\u002Ftouch-and-pen.md) for examples and options.\n\n### Read element state\n```powershell\n# Read text\u002Fvalue content (works for RichEditBox, TextBox, ComboBox, Slider, labels)\nwinapp ui get-value doc-texteditor-53ad -a notepad\nwinapp ui get-value SearchBox -a myapp\nwinapp ui get-value CmbTheme -a myapp              # reads ComboBox selected item via SelectionPattern\n\n# Check toggle\u002Fselection state, value, scroll position\nwinapp ui get-property chk-agreecheckbox-b2c3 -a myapp --property ToggleState\nwinapp ui get-property txt-textbox-a4b1 -a myapp --property Value\nwinapp ui get-property cmb-modellist-d5e6 -a myapp --property IsSelected\n\n# Read formatting across the whole text document (not the selection)\nwinapp ui get-property Document -a myapp --property FontWeight --json\n\n# See what has keyboard focus\nwinapp ui get-focused -a myapp\n```\n\nFor `get-focused`, `-a` includes windows in the selected process; `-w` restricts\nfocus to that exact window, excluding its owned popups. A control can belong to\nthe target through its parent window even when it omits its own process ID.\nSee `references\u002Fui-json-envelope.md` for focus no-match and query-error handling.\n\nTo check a blank or cleared field, use `winapp ui wait-for SearchBox -a myapp --value \"\"`.\nSee [empty-value behavior](https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fwinappcli\u002Fblob\u002Fmain\u002Fdocs\u002Fui-automation.md#get-value)\nfor JSON output and reading the accessibility label separately.\n\n`get-property` also accepts `FontName`, `FontSize`, `ForegroundColor`, `IsItalic`,\nand `StrikethroughStyle`. Omit `--property` to include all six formatting attributes.\nTreat `Mixed`, `NotSupported`, and `Unavailable` as distinct states, not formatting\nvalues. Names are case-sensitive; unknown names fail with `invalid_arguments`.\nSee the [formatting reference](https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fwinappcli\u002Fblob\u002Fmain\u002Fdocs\u002Fui-automation.md#whole-document-text-formatting)\nfor units and state meanings, and `references\u002Fui-json-envelope.md` for the JSON shape.\n\n### Set values\nTo prepare a control for keyboard input, use `winapp ui focus \u003Cselector> -a \u003Capp>`\n(keep `--on sandbox` when working in Sandbox). It activates the control's window\nand verifies both foreground and keyboard focus before success. It restores a\nminimized window first. If a command reports the target window is minimized (some\napps, such as Calculator, hide their UI until restored), run\n`winapp ui focus -a \u003Capp>` (no selector) to restore and activate it, then retry. Do not use a\nscreenshot as a focus workaround. If activation is refused, inspect for a blocking\ndialog and ask the user to activate the intended window; do not retry in a loop\nor switch to the local desktop. See the [focus reference](https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fwinappcli\u002Fblob\u002Fmain\u002Fdocs\u002Fui-automation.md#focus)\nfor failure codes and recovery.\n\n`set-value` writes programmatically (no keystrokes, no foreground) via a fallback chain: ValuePattern → RangeValuePattern (numeric) → LegacyIAccessible `put_accValue` for TextPattern-only edit controls.\n```powershell\nwinapp ui set-value txt-searchbox-e5f6 \"hello\" -a myapp        # TextBox\u002FComboBox via ValuePattern\nwinapp ui set-value sld-volume-b2c3 75 -a myapp                # Slider via RangeValuePattern\nwinapp ui set-value doc-compose-9f3a \"hello\" -a myapp          # RichEdit\u002Fcompose box via LegacyIAccessible\n```\n- The LegacyIAccessible fallback reaches rich-edit\u002Fcompose controls that expose no ValuePattern, as long as their accessibility implements `put_accValue` (native Win32 rich-edit and Chromium\u002FElectron\u002FWebView2 compose boxes typically do).\n- **WinUI 3 `RichEditBox` and WPF `RichTextBox` don't support programmatic value-setting** — by design they're read-only to UI Automation's value APIs (Text pattern, no settable Value pattern). `set-value` fails on them with a clear error — use `send-keys` (needs an unlocked, foregrounded desktop) to type into those instead. Note `get-value` can still *read* them via TextPattern.\n\n### Scroll containers\n```powershell\n# Find scrollable containers — look for [scroll:v] (vertical) or [scroll:h] (horizontal)\nwinapp ui search scroll -a myapp\n# Output:\n#   pn-scrollview-bfef Pane \"scrollView\" [scroll:v] (2127,296 1191x965)\n#   pn-scrollviewer-bfb1 Pane \"scrollViewer\" [scroll:h] (2127,296 1191x216)\n\n# Scroll vertically\nwinapp ui scroll pn-scrollview-bfef --direction down -a myapp\n\n# Scroll to top\u002Fbottom\nwinapp ui scroll pn-scrollview-bfef --to bottom -a myapp\n\n# Scroll and then inspect for newly visible elements\nwinapp ui scroll pn-scrollview-bfef --direction down -a myapp; winapp ui search TargetItem -a myapp\n\n# Synthesize real mouse-wheel input over the element (1 = one notch up, -1 = down) — tests wheel handlers (zoom, custom scroll)\nwinapp ui scroll img-map-a1b2 --wheel -1 -a myapp\n\n# Horizontal (tilt) wheel: 1 = one notch right, -1 = left — pans timelines and other horizontal-wheel handlers\nwinapp ui scroll pn-timeline-c3d4 --wheel-horizontal 3 -a myapp\n```\n\n### Wait for UI state\n```powershell\nwinapp ui wait-for btn-submit-a1b2 -a myapp --timeout 5000\nwinapp ui wait-for itm-status-c3d4 -a myapp --value \"Complete\" --timeout 5000\n```\n\n## Tips\n- Use `--interactive` with `inspect` as your first command — it shows only what you can act on\n- Chain commands with `;` to reduce round-trips (see note below on why not `&&`)\n- Use slugs from output to target specific elements — they're hash-validated and shell-safe\n- Use plain text search to find elements: `search Minimize`, `invoke Submit`\n- When text matches several elements, the only element named exactly that text wins; if several still match, the error shows slugs for each — pick the right one\n- Use `get-property --property ToggleState` to verify checkbox\u002Ftoggle state after invoke\n- `scroll` auto-finds the nearest scrollable parent\n- To capture one item in an open menu, flyout, tooltip, or teaching tip, pass its selector to `screenshot` or `record`; it is captured from its popup window\n- Follow [Screenshot](#screenshot) to select a window with `-w \u003Chwnd> --capture-screen` when you need popups in place over the window, or overlays the app doesn't own\n- Follow [Hover](#hover-for-tooltips-flyouts-hover-states) to capture tooltips and hover-triggered UI in place\n- Use `--focus` to foreground the target window before capture without switching to screen-DC capture (default capture path uses Windows.Graphics.Capture and works while occluded)\n- Use `--hide-disabled` and `--hide-offscreen` to reduce noise\n\n### Why `;` instead of `&&`\nUse `;` (not `&&`) to chain commands. PowerShell's `&&` operator can freeze when a native CLI writes to stderr or uses ANSI escape sequences — this causes a pipeline deadlock. `;` runs each command unconditionally and avoids this issue. This is also better for agent workflows: you usually want the screenshot to run even if the invoke had a non-zero exit (to see what went wrong).\n\n### File dialog workaround\nFile open\u002Fsave dialogs are standard Windows dialogs with UIA support. Interact with them using existing commands:\n```powershell\n# 1. Trigger the dialog (e.g., click \"Open File\" button)\nwinapp ui invoke btn-openfilebtn-a2b3 -a myapp\n\n# 2. Find the dialog window\nwinapp ui list-windows -a myapp\n# → Shows the main window + the dialog HWND\n# Note: untitled zero-size windows are hidden by default; use --show-hidden to include them\n\n# 3. Target the dialog, type the file path, and confirm\nwinapp ui set-value txt-1148-c4d5 \"C:\\path\\to\\file.png\" -w \u003Cdialog-hwnd>\nwinapp ui invoke btn-open-e6f7 -w \u003Cdialog-hwnd>\n```\nNote: The filename input in standard file dialogs typically has AutomationId `1148`. Use `inspect -w \u003Cdialog-hwnd> --interactive` to discover the actual slugs.\n\n## JSON output envelopes\n\nUse each element's `selector` as its handle. Elements report `type` (not `controlType`) and `x`, `y`, `width`, and `height` in physical screen pixels.\nFor each `--json` shape, with examples and what changed in v0.3.1 and v0.6.3, see [JSON envelopes](references\u002Fui-json-envelope.md).\n\n## Automating in Windows Sandbox\n\n```powershell\nwinapp run . --on sandbox --detach\nwinapp ui inspect --on sandbox -a MyApp\nwinapp ui screenshot --on sandbox -a MyApp -o .\\result.png\n```\n\nUse `--detach` before follow-up UI commands, and retain `--on sandbox` with guest PIDs\nor window handles. Inject the same `WINAPP_UI_WORKFLOW_ID` into cooperating guest calls;\nfinish with `winapp ui yield --on sandbox` after all of them complete.\n\nUse `winapp-sandbox` for setup consent, connected-client requirements, brief focus\nchanges during setup\u002Freconnect, and capture recovery. App screenshots and recordings,\nincluding default filenames and `--frames` directories, return to the host.\n\n## Related skills\n- `winapp-sandbox` for running and automating apps in an isolated Windows Sandbox\n- `winapp-setup` for adding Windows SDK to your project\n- `winapp-package` for packaging apps as MSIX\n\n## Troubleshooting\n| Error | Cause | Solution |\n|---|---|---|\n| \"No running app found\" | Wrong name or app not running | Try process name, window title, or PID |\n| \"Multiple windows match\" | Several windows match `-a` | Use `-w \u003CHWND>` from the listed options |\n| \"Selector matched N elements\" | Text query matches multiple elements | Use a slug from the suggestions shown in the error, or from `inspect` output |\n| \"Element may have changed\" | Slug hash doesn't match current element | Re-run `inspect` to get fresh slugs |\n| \"does not support any invoke pattern\" | Element can't be invoked | The error shows the invokable ancestor slug if one exists — use that |\n| \"No UIA window found\" | UIA can't see the window | Use `list-windows` to find HWND, then `-w` |\n| Popup not in screenshot | Default capture path doesn't include unowned overlays | For one item in an open menu or flyout, pass its selector. To show popups in place or capture unowned overlays, follow [Screenshot](#screenshot) to select a window with `-w \u003Chwnd> --capture-screen` |\n| `foreground_not_target` from `--capture-screen` | Windows refused the activation (focus-stealing prevention, UAC prompt, another window activating itself), so a screen capture would have recorded the wrong window | Click the target window, close the window that stole focus, then retry — or drop `--capture-screen` to capture the window directly |\n| `element_not_found` during record | Selector given but element not in tree | Re-run `inspect` or `search` to get a fresh selector |\n| `ambiguous_selector` during record | Plain-text selector matched multiple elements | Use a slug from the suggestions in the error message, or from `inspect` output |\n| WGC unavailable during record | WGC capture init failed; no silent fallback | Check GPU\u002Fdriver; use `--capture-screen` to explicitly request screen DC capture |\n\n## CLI reference\n\nRun `winapp \u003Ccommand> --help` for current command options, or `winapp --cli-schema` for the complete machine-readable command schema.\n",{"name":5,"description":7},"main","886c8edcdc7ca26e1e2947a12d81a91d6a9334a5","plugins\u002Fwinapp\u002Fskills\u002Fwinapp-ui-automation",96,"https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FwinappCli","https:\u002F\u002Fgithub.com\u002Fmicrosoft","https:\u002F\u002Fopensource.microsoft.com","Open source projects and samples from Microsoft","2026-11-14 07:14:37",{"source":8,"skillName":5,"commands":65,"prompt":75,"zipAvailable":76},[66,69,72],{"tool":67,"command":68},"npx","npx skills add microsoft\u002FwinappCli --skill winapp-ui-automation",{"tool":70,"command":71},"bunx","bunx skills add microsoft\u002FwinappCli --skill winapp-ui-automation",{"tool":73,"command":74},"pnpm","pnpm dlx skills add microsoft\u002FwinappCli --skill winapp-ui-automation","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FwinappCli\u002Fblob\u002Fmain\u002Fplugins\u002Fwinapp\u002Fskills\u002Fwinapp-ui-automation\u002FSKILL.md",true,[78,84],{"path":79,"resourceType":80,"resourceTypeDesc":81,"sizeBytes":82,"sourceHtmlUrl":83},"references\u002Ftouch-and-pen.md","REFERENCE","参考文档",2699,"https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FwinappCli\u002Fblob\u002Fmain\u002Fplugins\u002Fwinapp\u002Fskills\u002Fwinapp-ui-automation\u002Freferences\u002Ftouch-and-pen.md",{"path":85,"resourceType":80,"resourceTypeDesc":81,"sizeBytes":86,"sourceHtmlUrl":87},"references\u002Fui-json-envelope.md",11844,"https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FwinappCli\u002Fblob\u002Fmain\u002Fplugins\u002Fwinapp\u002Fskills\u002Fwinapp-ui-automation\u002Freferences\u002Fui-json-envelope.md",[89,112,136,161,182,197],{"skillNo":90,"name":91,"nameZh":6,"description":92,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":93,"categories":94,"keywords":95,"publishedAt":50},"01M699M75MK9AADQV8PQQQ6NEV","winui-wpf-migration","Migrate or port a WPF app to WinUI 3: namespaces (System.Windows to Microsoft.UI.Xaml), control mapping (DataGrid, WrapPanel, TabControl), Dispatcher to DispatcherQueue, imaging, MVVM with CommunityToolkit.Mvvm, ThemeResource. Use when converting WPF code or fixing migration build errors.","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FwinappCli\u002Fblob\u002Fmain\u002Fplugins\u002Fwinui\u002Fagent-plugin\u002Fskills\u002Fwinui-wpf-migration\u002FSKILL.md",[],[96,97,98,99,9,49,100,101,47,31,102,103,104,105,46,106,107,108,109,110,111],"winui wpf migration","winui","wpf","migration","dispatcher","code","migrate","system","use","mvvm","mapping","port","imaging","errors","namespaces","when",{"skillNo":113,"name":114,"nameZh":6,"description":115,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":116,"categories":117,"keywords":122,"publishedAt":50},"01M699M4W3GKSVVT9CRR1E3KSW","winui-ui-testing","Write and run automated UI tests for Windows desktop apps (WinUI 3, WPF, WinForms, Win32) with the winapp ui harness: one batch script, assertions, input, file pickers, dialogs, screenshots, locally or in Windows Sandbox. Use when asked for UI tests or to verify a feature end to end.","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FwinappCli\u002Fblob\u002Fmain\u002Fplugins\u002Fwinui\u002Fagent-plugin\u002Fskills\u002Fwinui-ui-testing\u002FSKILL.md",[118,121],{"categoryNo":119,"categoryName":120,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000008","测试与质量",{"categoryNo":24,"categoryName":25,"taxonomyType":26,"taxonomyTypeDesc":27},[123,124,97,31,125,48,126,49,127,33,128,129,130,131,132,41,133,37,134,135,111],"testing","winui ui testing","ui testing","sandbox","run","harness","batch","write","feature","end","input","desktop apps","for",{"skillNo":137,"name":138,"nameZh":6,"description":139,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":140,"categories":141,"keywords":145,"publishedAt":50},"01M699M2KTEYJZBDW7JBHM94K0","winui-setup","Install and verify WinUI 3 prerequisites — .NET SDK 8.0.100+, WinApp CLI 0.7+, and Developer Mode; identify additional Native AOT and Windows Sandbox requirements. Use when the user asks to set up or repair the toolchain, or when another WinUI skill finds a missing or outdated prerequisite.","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FwinappCli\u002Fblob\u002Fmain\u002Fplugins\u002Fwinui\u002Fagent-plugin\u002Fskills\u002Fwinui-setup\u002FSKILL.md",[142],{"categoryNo":143,"categoryName":144,"taxonomyType":26,"taxonomyTypeDesc":27},"01JBSEEDCAT000000000000030","开发工程师",[146,147,97,148,126,149,49,150,151,152,104,153,154,155,156,157,158,159,160,111],"winui setup","setup","cli","sdk","SET","verify","install","up","repair","requirements","missing","native","toolchain","winapp cli","mode",{"skillNo":162,"name":163,"nameZh":6,"description":164,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":165,"categories":166,"keywords":170,"publishedAt":50},"01M699KZWEZ84A4J3291E6R65B","winui-packaging","MSIX packaging, signing, and Microsoft Store publishing for WinUI 3 apps with WinApp CLI 0.7+: project packaging, Native AOT, certificates, self-contained deployment, CI\u002FCD. Use when releasing or publishing a WinUI app. Not for WPF, WinForms, or Electron apps that only reference the Windows App SDK.","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FwinappCli\u002Fblob\u002Fmain\u002Fplugins\u002Fwinui\u002Fagent-plugin\u002Fskills\u002Fwinui-packaging\u002FSKILL.md",[167],{"categoryNo":168,"categoryName":169,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000011","运维与部署",[171,97,172,148,149,173,9,174,49,175,176,177,178,179,180,46,41,37,157,181,159,135,111],"winui packaging","packaging","electron","msix","windows app sdk","ci","certificates","only","self","project","CI\u002FCD",{"skillNo":183,"name":184,"nameZh":6,"description":185,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":186,"categories":187,"keywords":188,"publishedAt":50},"01M699KXTHG9FHK4X3JSZ4SV8J","winui-dev-workflow","Create, build, run, and fix build errors in WinUI 3 apps (C# or C++) with WinApp CLI 0.7+: winapp new, winapp run, Native AOT, crash diagnosis. Use for a new WinUI app or a WinUI project that fails to build or crashes. Not for WPF, WinForms, or Electron apps that only reference the Windows App SDK.","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FwinappCli\u002Fblob\u002Fmain\u002Fplugins\u002Fwinui\u002Fagent-plugin\u002Fskills\u002Fwinui-dev-workflow\u002FSKILL.md",[],[189,190,97,191,192,148,149,173,49,193,127,194,178,180,46,195,41,37,157,159,109,196],"workflow","winui dev workflow","dev","dev workflow","create","fix","diagnosis","new",{"skillNo":198,"name":199,"nameZh":6,"description":200,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":201,"categories":202,"keywords":213,"publishedAt":50},"01M699KV0Q6NE5EET5EDBH33NM","winui-design","Read before writing or changing WinUI 3 XAML: choosing controls, pages and navigation, layout, Fluent Design, theming, accessibility, x:Bind, real samples, and checking that APIs exist with winapp find-api. Not for WPF or WinForms UI, even if the app uses the Windows App SDK.","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FwinappCli\u002Fblob\u002Fmain\u002Fplugins\u002Fwinui\u002Fagent-plugin\u002Fskills\u002Fwinui-design\u002FSKILL.md",[203,206,209,210],{"categoryNo":204,"categoryName":205,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000015","视觉设计",{"categoryNo":207,"categoryName":208,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000018","写作与文案",{"categoryNo":24,"categoryName":25,"taxonomyType":26,"taxonomyTypeDesc":27},{"categoryNo":211,"categoryName":212,"taxonomyType":26,"taxonomyTypeDesc":27},"01JBSEEDCAT000000000000036","内容创作者",[214,215,97,216,149,217,218,49,175,98,47,31,219,39,220,221,222,46,37,223,135,224],"design","winui design","writing","accessibility","fluent","api","layout","pages","bind","controls","fluent design"]