[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M79FA10V7SFPCVYFZVEB3G9M":3,"skill-same:01M79FA10V7SFPCVYFZVEB3G9M":45},{"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":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":27,"repositoryHtmlUrl":28,"repositoryHomepageUrl":6,"ownerHtmlUrl":29,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":30,"install":31,"resources":44},"01M79FA10V7SFPCVYFZVEB3G9M","winui-ui-testing",null,"Automated UI testing for Windows desktop apps — generate a batch test script with the `winapp ui` UI Automation harness, run all tests in one pass, read results. Covers element assertions, interactions, value checking (TextBox, ComboBox, ToggleSwitch), keyboard shortcuts and typing (send-keys), hover, drag-and-drop, touch and pen input, file pickers, flyouts, dialogs, persistence, accessibility audits, and screenshot\u002Fvideo capture. Works on any Windows app (Win32, WPF, WinForms, WinUI 3, packaged or unpackaged).","BumpyClock\u002Fagent-templates","BumpyClock","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F1883824?v=4","01M79EW0FDP9MFXH1FKH800S7T","Aditya Sharma","01M79EW0G27TTKZWTFQ8W5HVB4",2,"MIT","https:\u002F\u002Fgithub.com\u002FBumpyClock\u002Fagent-templates\u002Fblob\u002Fmain\u002Fskills_archive\u002Fmerged-into-parent\u002Fwinui-ui-testing\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: winui-ui-testing\ndescription: \"Automated UI testing for Windows desktop apps — generate a batch test script with the `winapp ui` UI Automation harness, run all tests in one pass, read results. Covers element assertions, interactions, value checking (TextBox, ComboBox, ToggleSwitch), keyboard shortcuts and typing (send-keys), hover, drag-and-drop, touch and pen input, file pickers, flyouts, dialogs, persistence, accessibility audits, and screenshot\u002Fvideo capture. Works on any Windows app (Win32, WPF, WinForms, WinUI 3, packaged or unpackaged).\"\n---\n\n### Scope — any Windows app\n\n`winapp ui` drives Windows **UI Automation (UIA)**, the accessibility layer every Windows UI framework exposes, so the AutomationId-based approach in this skill works on **any** Windows desktop app: Win32, WPF, WinForms, and WinUI 3, packaged or unpackaged. The file-picker tests below already drive the OS's Win32 file dialog through the same verbs. For a non-WinUI app, use the same verbs and script template and skip the WinUI-specific gotchas (x:Bind `LostFocus` commit, ContentDialog selectors, MSIX relaunch).\n\n### Approach\n\nThe goal of this skill is to validate UI and app functionality automatically, without manual interaction, by exercising the app's UI elements, verifying their state, and asserting that the app behaves as expected under test conditions.\n\nThere are two main approaches:\n1. Interactive exploration — manually run the app, use `winapp ui \u003Ccommand>` to explore the UI tree, find AutomationIds, verify element properties, and test functionality interactively. This is useful for discovery, but slow and expensive if repeated for every test iteration.\n2. Scripted batch testing — generate a `ui-tests.ps1` script that exercises all UI elements and asserts expected behavior in one pass. This allows you to run the tests automatically, capture results, and iterate quickly without manually interacting with the app each time.\n\nUnless the user asked for interactive exploration, or you are unfamiliar with the code\u002Fapp or need to explore the UI tree to discover AutomationIds for hidden or dynamically generated elements (flyouts, dialogs, lazy-loaded content), **prefer scripted batch testing** — it is faster, repeatable, and produces a record of pass\u002Ffail results that can be reviewed and acted on.\n\n### `winapp ui` Verbs\n\n- **Query:** `status`, `list-windows`, `inspect`, `search`, `get-property`, `get-value`, `get-focused`, `wait-for`\n- **Interact:** `invoke`, `click`, `set-value`, `focus`, `scroll`, `scroll-into-view`\n- **Advanced input:** `send-keys` (synthetic keyboard + accelerators), `hover` (tooltips\u002Fflyouts), `drag` (drag-drop, reorder, sliders), `touch` (tap\u002Fswipe\u002Fpinch\u002Fstretch), `pen` (stylus ink, pressure\u002Ftilt\u002Feraser)\n- **Capture:** `screenshot`, `record` (H.264 MP4 video)\n\nRun `winapp ui --cli-schema` for the complete command structure as JSON, or `winapp ui \u003Cverb> --help` for any single verb.\n\n### Step 1: Use the Running App\n\nIf the app is already running, use its PID. **Do NOT relaunch** — use the PID already captured from the build step. If the app is not running, build and launch it using the guidance in the winui-dev-workflow skill.\n\n### Step 2: Write the Test Script\n\n**If you wrote the code:** Skip inspect — you already know all the AutomationIds and control structure from the XAML and code-behind. Write tests directly from that knowledge. Inspect misses popups, flyouts, dialogs, and lazy-loaded content anyway.\n\n**If you're verifying code you didn't write:** Run inspect first to discover the UI:\n```powershell\nwinapp ui inspect -a \u003CPID> --interactive\n```\nThen read the XAML files to find AutomationIds that aren't currently visible (flyout items, dialog buttons, secondary pages).\n\nCreate a `ui-tests.ps1` file that tests all the app's requirements in one pass:\n\n```powershell\n# ui-tests.ps1\nparam([Parameter(Mandatory)][int]$AppPid)\n# NOTE: Do NOT name the parameter $Pid — it's read-only in PowerShell\n\n$ErrorActionPreference = 'Continue'\n$pass = 0; $fail = 0; $results = @()\n\n# Get main window HWND (avoids PopupHost interference with JSON parsing)\n$windows = winapp ui list-windows -a $AppPid --json 2>$null | ConvertFrom-Json\n$hwnd = ($windows | Where-Object { $_.title -ne \"PopupHost\" } | Select-Object -First 1).hwnd\n\nfunction Test-UI {\n    param([string]$Name, [scriptblock]$Script)\n    # IMPORTANT: Inside $Script, use 'throw' to signal failure — NOT 'exit 1'\n    # (exit terminates the entire script, not just the test)\n    try {\n        $output = & $Script 2>&1\n        if ($LASTEXITCODE -eq 0) {\n            $script:pass++; $script:results += @{ name = $Name; status = \"PASS\" }\n        } else {\n            $script:fail++; $script:results += @{ name = $Name; status = \"FAIL\"; detail = \"$output\" }\n        }\n    } catch {\n        $script:fail++; $script:results += @{ name = $Name; status = \"FAIL\"; detail = \"$_\" }\n    }\n}\n\n# ─── Element Existence ───\nTest-UI \"NavHome exists\" { winapp ui wait-for \"NavHome\" -a $AppPid -t 3000 }\nTest-UI \"NavSettings exists\" { winapp ui wait-for \"NavSettings\" -a $AppPid -t 3000 }\n\n# ─── Navigation ───\nTest-UI \"Navigate to Settings\" { winapp ui invoke \"NavSettings\" -a $AppPid }\nTest-UI \"Settings page loaded\" { winapp ui wait-for \"TxtUserName\" -a $AppPid -t 3000 }\n\n# ─── Interactions ───\nTest-UI \"Set username\" { winapp ui set-value \"TxtUserName\" \"TestUser\" -a $AppPid }\nTest-UI \"Click Save\" { winapp ui invoke \"BtnSave\" -a $AppPid }  # commits the TextBox binding\nTest-UI \"Username value set\" {\n    winapp ui wait-for \"TxtUserName\" -a $AppPid --value \"TestUser\" -t 2000\n}\n\n# ─── Value assertions for different control types ───\nTest-UI \"Theme is System default\" {\n    winapp ui wait-for \"CmbTheme\" -a $AppPid --value \"System default\" -t 2000\n}\nTest-UI \"Logging is off\" {\n    winapp ui wait-for \"TglLogging\" -a $AppPid --value \"Off\" -t 2000\n}\n\n# ─── Accessibility Audit ───\n# Only audit controls in the app's main window (exclude OS picker\u002Fpopup controls)\n$allElements = (winapp ui inspect -a $AppPid --interactive --json 2>$null | ConvertFrom-Json).elements\n$appElements = @($allElements | Where-Object {\n    $_.type -match 'Button|TextBox|ComboBox|CheckBox|ToggleSwitch|TabItem|Edit' -and\n    $_.name -notmatch 'Minimize|Maximize|Close|System' -and          # window chrome\n    $_.className -notmatch 'PickerHost|#32770|CabinetWClass'         # OS dialogs\n})\n$missingId = @($appElements | Where-Object { -not $_.automationId })\nif ($missingId.Count -eq 0) {\n    $pass++; $results += @{ name = \"All app controls have AutomationId\"; status = \"PASS\" }\n} else {\n    $fail++\n    $names = ($missingId | ForEach-Object { \"$($_.type) '$($_.name)'\" }) -join \", \"\n    $results += @{ name = \"AutomationId coverage\"; status = \"FAIL\"; detail = \"Missing: $names\" }\n}\n\n# ─── State Screenshots (capture each meaningful state for visual review) ───\nNew-Item -ItemType Directory -Force -Path \"screenshots\" | Out-Null\nwinapp ui screenshot -a $AppPid -o \"screenshots\u002F01-initial.png\" 2>$null\n# ...take more screenshots after key interactions above (mode switches, dialogs opened, etc.)\n\n# ─── Final Screenshot ───\nwinapp ui screenshot -a $AppPid -o \"test-screenshot.png\" 2>$null\n\n# ─── Results ───\nWrite-Host \"`nPassed: $pass | Failed: $fail\"\n$results | Where-Object { $_.status -eq \"FAIL\" } | ForEach-Object {\n    Write-Host \"  FAIL: $($_.name) — $($_.detail)\" -ForegroundColor Red\n}\n$results | ConvertTo-Json | Out-File \"test-results.json\"\nif ($fail -gt 0) { exit 1 } else { exit 0 }\n```\n\n### What to Test\n\nWrite tests for **every requirement** from the user's prompt:\n\n| Requirement type | Test approach |\n|---|---|\n| \"Has a button that does X\" | `search` to verify exists, `invoke` to click, `wait-for --value` to check result |\n| \"Text field shows value\" | `wait-for \"TxtName\" --value \"expected\"` — works for TextBox, TextBlock, labels |\n| \"Status bar contains text\" | `wait-for \"StatusBar\" --value \"words\" --contains` — substring match for dynamic content |\n| \"Dropdown is set to X\" | `wait-for \"CmbTheme\" --value \"Dark\"` — reads the selected item automatically |\n| \"Toggle is on\u002Foff\" | `wait-for \"TglFeature\" --value \"On\"` — reads the toggle state |\n| \"Navigation between pages\" | `invoke` nav item, `wait-for` a page-specific element to appear |\n| \"Open file dialog\" | `invoke` trigger, `list-windows` to find picker HWND, interact with `-w` |\n| \"Save file dialog\" | Same as open — find picker with `list-windows`, `set-value` filename, `invoke` Save |\n| \"Right-click context menu\" | `click --right` on element, `invoke` the flyout MenuItem |\n| \"Keyboard shortcut (Ctrl+S, etc.)\" | `send-keys \"ctrl+s\" --via send-input` then `wait-for` the result |\n| \"Type into a TextBox\u002FRichEditBox\" | `send-keys \"text\" --target \"Id\" --via send-input` (real per-key input) |\n| \"Tooltip \u002F hover flyout appears\" | `hover` the element, then `wait-for` the tooltip\u002Fflyout |\n| \"Drag to reorder \u002F resize \u002F slider\" | `drag \u003Cfrom> \u003Cto>` then `wait-for --value` the new state |\n| \"Touch gesture (swipe\u002Fpinch\u002Fstretch)\" | `touch -g swipe\u002Fpinch\u002Fstretch` then assert the result |\n| \"Capture a repro clip of a flow\" | `record -a PID --duration-sec N -o clip.mp4` |\n| \"Confirmation dialog\" | `invoke` trigger, `search` for dialog buttons, `invoke` Primary\u002FSecondary\u002FClose |\n| \"Data persists\" | Set values, `invoke` a button (to commit bindings), verify data file on disk (`Get-Content` + `ConvertFrom-Json`) |\n| \"All controls accessible\" | `inspect --interactive --json` + check all have AutomationId |\n\n### Step 3: Run and Read Results\n\n```powershell\n.\\ui-tests.ps1 -AppPid \u003CPID>\n```\n\nRead `test-results.json` for structured pass\u002Ffail. Only fix code if tests fail.\n\n### Step 3.5: Look at the Screenshots\n\nUIA assertions don't see clipping, overlap, wrong theming, or controls bleeding past their container — UIA returns `PASS` while the app is visually broken. **Capture screenshots with `winapp ui screenshot` and view each PNG.**\n\nCapture the initial state and any state after a major interaction (the State Screenshots block in the script template above handles this).\n\n**Visual checklist — fail the run if any item is `no`:**\n- [ ] No unintended scrollbars\n- [ ] No text ending in `…` that shouldn't be\n- [ ] Hero elements fully visible (not sliced)\n- [ ] Right-edge controls fully visible\n- [ ] No overlapping rows\n- [ ] Content uses the available width — no asymmetric dead zones (e.g. content pinned to one edge leaving empty space on the other)\n- [ ] Spacing intentional — not cramped, not unintentionally vast\n- [ ] Theming matches the user's ask (Light\u002FDark\u002FHighContrast if relevant)\n- [ ] Focus\u002Fhover\u002Ferror states render if tested\n\nIf the checklist fails, it's a bug — fix before declaring done. Window too small → grow per `winui-design` Step 4.\n\n### Step 4: Fix and Rerun (if the user asked for it)\n\nIf tests fail:\n1. Read the failure details from `test-results.json`\n2. Batch-fix all issues in one pass\n3. Rebuild with `.\\BuildAndRun.ps1` (blocking mode — shows crash info if the fix broke something)\n4. Rerun `.\\ui-tests.ps1 -AppPid \u003CPID>` (parse PID from the `launched (PID: XXXXX)` output)\n\n**Maximum 2 fix-and-rerun cycles.** If the same tests keep failing after 2 cycles, report them as known issues and move on — do not keep iterating.\n\n### Assertion Reference\n\nUse `wait-for --value` as the primary assertion — it uses a smart fallback chain that reads the right value for any control type:\n\n| Control type | `--value` reads from | Example |\n|---|---|---|\n| TextBlock \u002F Label | Name property | `wait-for \"LblTitle\" --value \"Home\"` |\n| TextBox \u002F NumberBox | ValuePattern | `wait-for \"TxtName\" --value \"John\"` |\n| RichEditBox | TextPattern | `wait-for \"Editor\" --value \"Hello\"` |\n| ComboBox | Selected item (SelectionPattern) | `wait-for \"CmbTheme\" --value \"Dark\"` |\n| ToggleSwitch | Toggle state (On\u002FOff) | `wait-for \"TglDark\" --value \"On\"` |\n| CheckBox | Toggle state (On\u002FOff) | `wait-for \"ChkAgree\" --value \"On\"` |\n\n**Full assertion commands:**\n\n| Assertion | Command |\n|---|---|\n| Element exists | `winapp ui wait-for \"Id\" -a PID -t 3000` |\n| Element has exact value | `winapp ui wait-for \"Id\" -a PID --value \"expected\" -t 3000` |\n| Value contains text | `winapp ui wait-for \"Id\" -a PID --value \"words\" --contains -t 3000` |\n| Element gone | `winapp ui wait-for \"Id\" -a PID --gone -t 3000` |\n| Specific property | `winapp ui wait-for \"Id\" -a PID -p IsEnabled --value \"True\" -t 3000` |\n| Button clickable | `winapp ui invoke \"Id\" -a PID` (exit code 0) |\n| Set then verify | `winapp ui set-value \"Id\" \"text\" -a PID` then `wait-for --value` |\n| Screenshot | `winapp ui screenshot -a PID -o path.png` |\n| Dialog appeared | `winapp ui list-windows -a PID --json` (check window count) |\n| Right-click menu | `winapp ui click \"Id\" -a PID --right` then `wait-for` menu item |\n| Read raw property | `winapp ui get-property \"Id\" -a PID -p IsEnabled --json` |\n| Read current value (no wait) | `(winapp ui get-value \"Id\" -a PID --json \\| ConvertFrom-Json).text` — always pass `--json` when capturing into a variable (plain stdout can include advisory text like \"Auto-selected HWND … from N windows\"); otherwise prefer `wait-for --value` |\n| Scroll item into view | `winapp ui scroll-into-view \"Id\" -a PID` — call before `wait-for` on virtualized ListView\u002Frepeater items below the fold |\n| Set keyboard focus | `winapp ui focus \"Id\" -a PID` — cleaner than clicking another control to trigger a TextBox `LostFocus` commit |\n| Type real keystrokes into a control | `winapp ui send-keys \"text\" --target \"Id\" -a PID --via send-input` |\n| Fire a keyboard accelerator\u002Fshortcut | `winapp ui send-keys \"ctrl+s\" -a PID --via send-input` |\n| Hover to show tooltip\u002Fflyout | `winapp ui hover \"Id\" -a PID` then `wait-for` |\n| Drag \u002F reorder \u002F slider gesture | `winapp ui drag \"From\" \"To\" -a PID` |\n| Touch gesture | `winapp ui touch \"Id\" -g swipe --direction up -a PID` |\n| Pen \u002F ink stroke | `winapp ui pen \"InkCanvas\" --path \"x,y x,y\" -a PID` |\n| Record a video clip | `winapp ui record -a PID --duration-sec N -o clip.mp4` |\n\n### Testing File Pickers\n\nFile\u002Ffolder pickers (FileOpenPicker, FileSavePicker, FolderPicker) run in a separate `PickerHost` process but are fully interactable. The picker appears as an owned dialog window.\n\n```powershell\n# 1. Trigger the picker\nwinapp ui invoke \"BtnOpenFile\" -a $AppPid\n\n# 2. Find the picker window (it's a dialog owned by the app window)\nStart-Sleep 1\n$allWindows = winapp ui list-windows -a $AppPid --json 2>$null | ConvertFrom-Json\n$picker = $allWindows | Where-Object { $_.title -match \"Open|Save\" }\n$pickerHwnd = $picker.hwnd\n\n# 3. Interact with the picker using -w \u003CHWND>\n#    Type a filename:\nwinapp ui set-value \"FileNameControlHost\" \"test.txt\" -w $pickerHwnd\n#    Click Open\u002FSave:\nwinapp ui invoke \"Open\" -w $pickerHwnd     # or \"Save\", \"Cancel\"\n#    Or cancel:\nwinapp ui invoke \"Cancel\" -w $pickerHwnd\n\n# 4. Verify the app processed the file\nwinapp ui wait-for \"StatusBar\" -a $AppPid -p Name --value \"opened\" -t 3000\n```\n\n**Tip:** Use `winapp ui inspect -w \u003CpickerHwnd> --interactive` to discover the picker's controls — they include the folder tree, file list, filename textbox, and Open\u002FCancel buttons.\n\n### Testing Context Menus and Flyouts\n\nMenuFlyouts and ContextFlyouts are fully testable. They appear in the UI automation tree when open.\n\n```powershell\n# 1. Right-click to open a ContextFlyout\nwinapp ui click \"LstItems\" -a $AppPid --right\nStart-Sleep 0.5\n\n# 2. The flyout MenuItems appear in the tree immediately\n#    Find them with inspect or search:\nwinapp ui inspect -a $AppPid --interactive   # shows MnuCopy, MnuDelete, etc.\n\n# 3. Click a flyout item\nwinapp ui invoke \"MnuCopy\" -a $AppPid\n\n# 4. Verify the action\nwinapp ui wait-for \"StatusText\" -a $AppPid -p Name --value \"Copied\" -t 2000\n```\n\n**For MenuBar flyouts** (File, Edit, View menus):\n```powershell\n# Click the menu header to open\nwinapp ui invoke \"FileMenu\" -a $AppPid\nStart-Sleep 0.5\n# Click the sub-item\nwinapp ui invoke \"MenuSaveAs\" -a $AppPid\n```\n\n### Testing ContentDialogs\n\nContentDialogs are in-app controls (same window) — they appear directly in the UI tree when shown.\n\n```powershell\n# 1. Trigger the dialog\nwinapp ui invoke \"BtnDelete\" -a $AppPid\nStart-Sleep 0.5\n\n# 2. The dialog buttons appear in the tree\n#    For a standard confirmation dialog:\nwinapp ui search \"Primary\" -a $AppPid --json   # finds the primary button\nwinapp ui invoke \"Primary\" -a $AppPid           # click \"Yes\"\u002F\"Delete\"\u002F\"Save\"\n#    Or:\nwinapp ui invoke \"Secondary\" -a $AppPid         # click \"No\"\u002F\"Don't Save\"\nwinapp ui invoke \"Close\" -a $AppPid             # click \"Cancel\"\n\n# 3. Wait for dialog to dismiss\nwinapp ui wait-for \"Primary\" -a $AppPid --gone -t 3000\n```\n\n**Tip:** ContentDialog buttons often don't have custom AutomationIds — use `inspect` to find the actual selector (slug or text match).\n\n### Advanced Input: keyboard, hover, drag, touch & pen\n\nSynthetic input beyond `invoke`\u002F`click`\u002F`set-value`. Each verb takes `-a \u003CPID>` \u002F `-w \u003CHWND>` like the rest.\n\n**`send-keys` — real keyboard input.** Named keys (`enter`, `tab`, `f5`), combos (`ctrl+shift+t`), raw `vk=0x42`, or literal text. `--via` selects the transport:\n- `post-message` (default) — HWND-targeted, no foreground needed; raises `TextChanged` but **not** per-character `KeyDown`.\n- `send-input` — OS-wide; real per-character `KeyDown` + `TextChanged`. **Required for accelerators\u002Fshortcuts** (`KeyboardAccelerator`, e.g. `ctrl+t`) and for reliable typing into a WinUI 3 \u002F WPF `TextBox`.\n\n```powershell\nwinapp ui send-keys \"ctrl+s\" -a $AppPid --via send-input                          # fire a Ctrl+S accelerator\nwinapp ui send-keys \"hello world\" --target \"TxtName\" -a $AppPid --via send-input  # focus then type\nwinapp ui send-keys --verbatim \"down down enter\" -a $AppPid                       # type the words, not the keys\n```\n`--target` focuses first; `text=\u003Cliteral>` \u002F `--verbatim` type literally instead of interpreting key names. System combos (`win+r`, `alt+f4`) need `--allow-system-keys` + `--via send-input` (`win+l` stays blocked).\n\n**`hover` — tooltips, flyouts, hover states.** Dwells on the element (`--dwell-time`, default 800 ms) so hover-triggered UI appears in the tree.\n```powershell\nwinapp ui hover \"BtnInfo\" -a $AppPid\nwinapp ui wait-for \"InfoTooltip\" -a $AppPid -t 2000\n```\n\n**`drag` — drag-drop, reorder, resize, sliders.** `\u003Cfrom>`\u002F`\u003Cto>` are each an element selector (its center) or screen `x,y` from `inspect`. `--hold-ms` long-presses before moving; `--dwell-ms` settles on the target before releasing (merge\u002Flatch targets).\n```powershell\nwinapp ui drag \"ItemA\" \"ItemB\" -a $AppPid          # reorder ItemA onto ItemB\nwinapp ui drag \"SldVolume\" 300,120 -a $AppPid      # drag a slider thumb to a point\n```\n\n**`touch` — touch gestures.** `-g`: `tap` (default), `double-tap`, `long-press`, `swipe`, `pinch`, `stretch`; `--direction`\u002F`--distance`\u002F`--to-point` for swipes, `--fingers` for multi-touch. Needs an unlocked interactive desktop with the window foregroundable.\n```powershell\nwinapp ui touch \"LstFeed\" -g swipe --direction up --distance 400 -a $AppPid\nwinapp ui touch \"ImgPhoto\" -g stretch --distance 200 -a $AppPid    # pinch-to-zoom\n```\n\n**`pen` — pen\u002Fstylus.** Taps or draws ink; `--path \"x,y x,y …\"` for a multi-point stroke, with `--pressure`, `--tilt-x`\u002F`--tilt-y`, `--eraser` (Win10 1809+).\n```powershell\nwinapp ui pen \"InkCanvas\" --path \"50,50 120,80 200,60\" --pressure 0.8 -a $AppPid\nwinapp ui pen \"InkCanvas\" --path \"50,50 200,60\" --eraser -a $AppPid\n```\n\n### Recording a Video\n\n`winapp ui record` captures the target window (or an element region) to an H.264 MP4 — handy for a repro clip of a flow or animation. Records until stopped (newline\u002FEOF on stdin, or Ctrl+C); `--duration-sec N` gives a fixed-length clip (simplest for scripts). The MP4 is finalized on graceful stop.\n\n```powershell\nwinapp ui record -a $AppPid --duration-sec 6 --fps 30 -o \"flow.mp4\"\n```\n`--max-edge N` downscales large windows; `--capture-screen` uses screen BitBlt to include popups\u002Foverlays outside the target window (also on `screenshot`).\n\n### Key Gotchas\n\n- **`set-value` does NOT commit default TextBox bindings** — WinUI 3 `x:Bind TwoWay` on TextBox.Text updates the ViewModel on `LostFocus` by default. UIA `set-value` changes the text but doesn't trigger focus events. **Fix:** apps should use `UpdateSourceTrigger=PropertyChanged` on TextBox bindings (see design skill). If the app doesn't, `invoke` a button or `click`\u002F`focus` another element after `set-value` to trigger `LostFocus`.\n- **Set a `RichEditBox` with `send-keys`, not `set-value`** — WinUI 3 `RichEditBox` \u002F WPF `RichTextBox` don't support UIA value-setting. `focus` (or `--target`), then `send-keys \"…\" --via send-input` — which also raises real per-key `KeyDown`, so use it whenever a control reacts to individual keystrokes (or a `KeyboardAccelerator`) rather than a bulk value change.\n- **Verify persistence via the data file, not UI relaunch** — killing and relaunching a packaged app from a test script is fragile (MSIX registration timing, PID issues). Instead, check the data file on disk: `Get-Content $dataFile | ConvertFrom-Json` and verify expected values.\n- **Use `$AppPid` not `$Pid`** — `$Pid` is a read-only automatic variable in PowerShell\n- **Use `--value` without `-p`** — it auto-detects the right UIA pattern (TextPattern → ValuePattern → TogglePattern → SelectionPattern → Name). Only use `-p PropertyName --value` when you need a specific property like `IsEnabled`\n- **File pickers need `-w \u003CHWND>`** — they run in a separate PickerHost process, so `-a PID` won't find them. Use `list-windows` to discover the picker HWND first\n- **Flyouts need a short `Start-Sleep`** after triggering — the menu items appear in the tree asynchronously\n\n","### Scope — any Windows app\n\n`winapp ui` drives Windows **UI Automation (UIA)**, the accessibility layer every Windows UI framework exposes, so the AutomationId-based approach in this skill works on **any** Windows desktop app: Win32, WPF, WinForms, and WinUI 3, packaged or unpackaged. The file-picker tests below already drive the OS's Win32 file dialog through the same verbs. For a non-WinUI app, use the same verbs and script template and skip the WinUI-specific gotchas (x:Bind `LostFocus` commit, ContentDialog selectors, MSIX relaunch).\n\n### Approach\n\nThe goal of this skill is to validate UI and app functionality automatically, without manual interaction, by exercising the app's UI elements, verifying their state, and asserting that the app behaves as expected under test conditions.\n\nThere are two main approaches:\n1. Interactive exploration — manually run the app, use `winapp ui \u003Ccommand>` to explore the UI tree, find AutomationIds, verify element properties, and test functionality interactively. This is useful for discovery, but slow and expensive if repeated for every test iteration.\n2. Scripted batch testing — generate a `ui-tests.ps1` script that exercises all UI elements and asserts expected behavior in one pass. This allows you to run the tests automatically, capture results, and iterate quickly without manually interacting with the app each time.\n\nUnless the user asked for interactive exploration, or you are unfamiliar with the code\u002Fapp or need to explore the UI tree to discover AutomationIds for hidden or dynamically generated elements (flyouts, dialogs, lazy-loaded content), **prefer scripted batch testing** — it is faster, repeatable, and produces a record of pass\u002Ffail results that can be reviewed and acted on.\n\n### `winapp ui` Verbs\n\n- **Query:** `status`, `list-windows`, `inspect`, `search`, `get-property`, `get-value`, `get-focused`, `wait-for`\n- **Interact:** `invoke`, `click`, `set-value`, `focus`, `scroll`, `scroll-into-view`\n- **Advanced input:** `send-keys` (synthetic keyboard + accelerators), `hover` (tooltips\u002Fflyouts), `drag` (drag-drop, reorder, sliders), `touch` (tap\u002Fswipe\u002Fpinch\u002Fstretch), `pen` (stylus ink, pressure\u002Ftilt\u002Feraser)\n- **Capture:** `screenshot`, `record` (H.264 MP4 video)\n\nRun `winapp ui --cli-schema` for the complete command structure as JSON, or `winapp ui \u003Cverb> --help` for any single verb.\n\n### Step 1: Use the Running App\n\nIf the app is already running, use its PID. **Do NOT relaunch** — use the PID already captured from the build step. If the app is not running, build and launch it using the guidance in the winui-dev-workflow skill.\n\n### Step 2: Write the Test Script\n\n**If you wrote the code:** Skip inspect — you already know all the AutomationIds and control structure from the XAML and code-behind. Write tests directly from that knowledge. Inspect misses popups, flyouts, dialogs, and lazy-loaded content anyway.\n\n**If you're verifying code you didn't write:** Run inspect first to discover the UI:\n```powershell\nwinapp ui inspect -a \u003CPID> --interactive\n```\nThen read the XAML files to find AutomationIds that aren't currently visible (flyout items, dialog buttons, secondary pages).\n\nCreate a `ui-tests.ps1` file that tests all the app's requirements in one pass:\n\n```powershell\n# ui-tests.ps1\nparam([Parameter(Mandatory)][int]$AppPid)\n# NOTE: Do NOT name the parameter $Pid — it's read-only in PowerShell\n\n$ErrorActionPreference = 'Continue'\n$pass = 0; $fail = 0; $results = @()\n\n# Get main window HWND (avoids PopupHost interference with JSON parsing)\n$windows = winapp ui list-windows -a $AppPid --json 2>$null | ConvertFrom-Json\n$hwnd = ($windows | Where-Object { $_.title -ne \"PopupHost\" } | Select-Object -First 1).hwnd\n\nfunction Test-UI {\n    param([string]$Name, [scriptblock]$Script)\n    # IMPORTANT: Inside $Script, use 'throw' to signal failure — NOT 'exit 1'\n    # (exit terminates the entire script, not just the test)\n    try {\n        $output = & $Script 2>&1\n        if ($LASTEXITCODE -eq 0) {\n            $script:pass++; $script:results += @{ name = $Name; status = \"PASS\" }\n        } else {\n            $script:fail++; $script:results += @{ name = $Name; status = \"FAIL\"; detail = \"$output\" }\n        }\n    } catch {\n        $script:fail++; $script:results += @{ name = $Name; status = \"FAIL\"; detail = \"$_\" }\n    }\n}\n\n# ─── Element Existence ───\nTest-UI \"NavHome exists\" { winapp ui wait-for \"NavHome\" -a $AppPid -t 3000 }\nTest-UI \"NavSettings exists\" { winapp ui wait-for \"NavSettings\" -a $AppPid -t 3000 }\n\n# ─── Navigation ───\nTest-UI \"Navigate to Settings\" { winapp ui invoke \"NavSettings\" -a $AppPid }\nTest-UI \"Settings page loaded\" { winapp ui wait-for \"TxtUserName\" -a $AppPid -t 3000 }\n\n# ─── Interactions ───\nTest-UI \"Set username\" { winapp ui set-value \"TxtUserName\" \"TestUser\" -a $AppPid }\nTest-UI \"Click Save\" { winapp ui invoke \"BtnSave\" -a $AppPid }  # commits the TextBox binding\nTest-UI \"Username value set\" {\n    winapp ui wait-for \"TxtUserName\" -a $AppPid --value \"TestUser\" -t 2000\n}\n\n# ─── Value assertions for different control types ───\nTest-UI \"Theme is System default\" {\n    winapp ui wait-for \"CmbTheme\" -a $AppPid --value \"System default\" -t 2000\n}\nTest-UI \"Logging is off\" {\n    winapp ui wait-for \"TglLogging\" -a $AppPid --value \"Off\" -t 2000\n}\n\n# ─── Accessibility Audit ───\n# Only audit controls in the app's main window (exclude OS picker\u002Fpopup controls)\n$allElements = (winapp ui inspect -a $AppPid --interactive --json 2>$null | ConvertFrom-Json).elements\n$appElements = @($allElements | Where-Object {\n    $_.type -match 'Button|TextBox|ComboBox|CheckBox|ToggleSwitch|TabItem|Edit' -and\n    $_.name -notmatch 'Minimize|Maximize|Close|System' -and          # window chrome\n    $_.className -notmatch 'PickerHost|#32770|CabinetWClass'         # OS dialogs\n})\n$missingId = @($appElements | Where-Object { -not $_.automationId })\nif ($missingId.Count -eq 0) {\n    $pass++; $results += @{ name = \"All app controls have AutomationId\"; status = \"PASS\" }\n} else {\n    $fail++\n    $names = ($missingId | ForEach-Object { \"$($_.type) '$($_.name)'\" }) -join \", \"\n    $results += @{ name = \"AutomationId coverage\"; status = \"FAIL\"; detail = \"Missing: $names\" }\n}\n\n# ─── State Screenshots (capture each meaningful state for visual review) ───\nNew-Item -ItemType Directory -Force -Path \"screenshots\" | Out-Null\nwinapp ui screenshot -a $AppPid -o \"screenshots\u002F01-initial.png\" 2>$null\n# ...take more screenshots after key interactions above (mode switches, dialogs opened, etc.)\n\n# ─── Final Screenshot ───\nwinapp ui screenshot -a $AppPid -o \"test-screenshot.png\" 2>$null\n\n# ─── Results ───\nWrite-Host \"`nPassed: $pass | Failed: $fail\"\n$results | Where-Object { $_.status -eq \"FAIL\" } | ForEach-Object {\n    Write-Host \"  FAIL: $($_.name) — $($_.detail)\" -ForegroundColor Red\n}\n$results | ConvertTo-Json | Out-File \"test-results.json\"\nif ($fail -gt 0) { exit 1 } else { exit 0 }\n```\n\n### What to Test\n\nWrite tests for **every requirement** from the user's prompt:\n\n| Requirement type | Test approach |\n|---|---|\n| \"Has a button that does X\" | `search` to verify exists, `invoke` to click, `wait-for --value` to check result |\n| \"Text field shows value\" | `wait-for \"TxtName\" --value \"expected\"` — works for TextBox, TextBlock, labels |\n| \"Status bar contains text\" | `wait-for \"StatusBar\" --value \"words\" --contains` — substring match for dynamic content |\n| \"Dropdown is set to X\" | `wait-for \"CmbTheme\" --value \"Dark\"` — reads the selected item automatically |\n| \"Toggle is on\u002Foff\" | `wait-for \"TglFeature\" --value \"On\"` — reads the toggle state |\n| \"Navigation between pages\" | `invoke` nav item, `wait-for` a page-specific element to appear |\n| \"Open file dialog\" | `invoke` trigger, `list-windows` to find picker HWND, interact with `-w` |\n| \"Save file dialog\" | Same as open — find picker with `list-windows`, `set-value` filename, `invoke` Save |\n| \"Right-click context menu\" | `click --right` on element, `invoke` the flyout MenuItem |\n| \"Keyboard shortcut (Ctrl+S, etc.)\" | `send-keys \"ctrl+s\" --via send-input` then `wait-for` the result |\n| \"Type into a TextBox\u002FRichEditBox\" | `send-keys \"text\" --target \"Id\" --via send-input` (real per-key input) |\n| \"Tooltip \u002F hover flyout appears\" | `hover` the element, then `wait-for` the tooltip\u002Fflyout |\n| \"Drag to reorder \u002F resize \u002F slider\" | `drag \u003Cfrom> \u003Cto>` then `wait-for --value` the new state |\n| \"Touch gesture (swipe\u002Fpinch\u002Fstretch)\" | `touch -g swipe\u002Fpinch\u002Fstretch` then assert the result |\n| \"Capture a repro clip of a flow\" | `record -a PID --duration-sec N -o clip.mp4` |\n| \"Confirmation dialog\" | `invoke` trigger, `search` for dialog buttons, `invoke` Primary\u002FSecondary\u002FClose |\n| \"Data persists\" | Set values, `invoke` a button (to commit bindings), verify data file on disk (`Get-Content` + `ConvertFrom-Json`) |\n| \"All controls accessible\" | `inspect --interactive --json` + check all have AutomationId |\n\n### Step 3: Run and Read Results\n\n```powershell\n.\\ui-tests.ps1 -AppPid \u003CPID>\n```\n\nRead `test-results.json` for structured pass\u002Ffail. Only fix code if tests fail.\n\n### Step 3.5: Look at the Screenshots\n\nUIA assertions don't see clipping, overlap, wrong theming, or controls bleeding past their container — UIA returns `PASS` while the app is visually broken. **Capture screenshots with `winapp ui screenshot` and view each PNG.**\n\nCapture the initial state and any state after a major interaction (the State Screenshots block in the script template above handles this).\n\n**Visual checklist — fail the run if any item is `no`:**\n- [ ] No unintended scrollbars\n- [ ] No text ending in `…` that shouldn't be\n- [ ] Hero elements fully visible (not sliced)\n- [ ] Right-edge controls fully visible\n- [ ] No overlapping rows\n- [ ] Content uses the available width — no asymmetric dead zones (e.g. content pinned to one edge leaving empty space on the other)\n- [ ] Spacing intentional — not cramped, not unintentionally vast\n- [ ] Theming matches the user's ask (Light\u002FDark\u002FHighContrast if relevant)\n- [ ] Focus\u002Fhover\u002Ferror states render if tested\n\nIf the checklist fails, it's a bug — fix before declaring done. Window too small → grow per `winui-design` Step 4.\n\n### Step 4: Fix and Rerun (if the user asked for it)\n\nIf tests fail:\n1. Read the failure details from `test-results.json`\n2. Batch-fix all issues in one pass\n3. Rebuild with `.\\BuildAndRun.ps1` (blocking mode — shows crash info if the fix broke something)\n4. Rerun `.\\ui-tests.ps1 -AppPid \u003CPID>` (parse PID from the `launched (PID: XXXXX)` output)\n\n**Maximum 2 fix-and-rerun cycles.** If the same tests keep failing after 2 cycles, report them as known issues and move on — do not keep iterating.\n\n### Assertion Reference\n\nUse `wait-for --value` as the primary assertion — it uses a smart fallback chain that reads the right value for any control type:\n\n| Control type | `--value` reads from | Example |\n|---|---|---|\n| TextBlock \u002F Label | Name property | `wait-for \"LblTitle\" --value \"Home\"` |\n| TextBox \u002F NumberBox | ValuePattern | `wait-for \"TxtName\" --value \"John\"` |\n| RichEditBox | TextPattern | `wait-for \"Editor\" --value \"Hello\"` |\n| ComboBox | Selected item (SelectionPattern) | `wait-for \"CmbTheme\" --value \"Dark\"` |\n| ToggleSwitch | Toggle state (On\u002FOff) | `wait-for \"TglDark\" --value \"On\"` |\n| CheckBox | Toggle state (On\u002FOff) | `wait-for \"ChkAgree\" --value \"On\"` |\n\n**Full assertion commands:**\n\n| Assertion | Command |\n|---|---|\n| Element exists | `winapp ui wait-for \"Id\" -a PID -t 3000` |\n| Element has exact value | `winapp ui wait-for \"Id\" -a PID --value \"expected\" -t 3000` |\n| Value contains text | `winapp ui wait-for \"Id\" -a PID --value \"words\" --contains -t 3000` |\n| Element gone | `winapp ui wait-for \"Id\" -a PID --gone -t 3000` |\n| Specific property | `winapp ui wait-for \"Id\" -a PID -p IsEnabled --value \"True\" -t 3000` |\n| Button clickable | `winapp ui invoke \"Id\" -a PID` (exit code 0) |\n| Set then verify | `winapp ui set-value \"Id\" \"text\" -a PID` then `wait-for --value` |\n| Screenshot | `winapp ui screenshot -a PID -o path.png` |\n| Dialog appeared | `winapp ui list-windows -a PID --json` (check window count) |\n| Right-click menu | `winapp ui click \"Id\" -a PID --right` then `wait-for` menu item |\n| Read raw property | `winapp ui get-property \"Id\" -a PID -p IsEnabled --json` |\n| Read current value (no wait) | `(winapp ui get-value \"Id\" -a PID --json \\| ConvertFrom-Json).text` — always pass `--json` when capturing into a variable (plain stdout can include advisory text like \"Auto-selected HWND … from N windows\"); otherwise prefer `wait-for --value` |\n| Scroll item into view | `winapp ui scroll-into-view \"Id\" -a PID` — call before `wait-for` on virtualized ListView\u002Frepeater items below the fold |\n| Set keyboard focus | `winapp ui focus \"Id\" -a PID` — cleaner than clicking another control to trigger a TextBox `LostFocus` commit |\n| Type real keystrokes into a control | `winapp ui send-keys \"text\" --target \"Id\" -a PID --via send-input` |\n| Fire a keyboard accelerator\u002Fshortcut | `winapp ui send-keys \"ctrl+s\" -a PID --via send-input` |\n| Hover to show tooltip\u002Fflyout | `winapp ui hover \"Id\" -a PID` then `wait-for` |\n| Drag \u002F reorder \u002F slider gesture | `winapp ui drag \"From\" \"To\" -a PID` |\n| Touch gesture | `winapp ui touch \"Id\" -g swipe --direction up -a PID` |\n| Pen \u002F ink stroke | `winapp ui pen \"InkCanvas\" --path \"x,y x,y\" -a PID` |\n| Record a video clip | `winapp ui record -a PID --duration-sec N -o clip.mp4` |\n\n### Testing File Pickers\n\nFile\u002Ffolder pickers (FileOpenPicker, FileSavePicker, FolderPicker) run in a separate `PickerHost` process but are fully interactable. The picker appears as an owned dialog window.\n\n```powershell\n# 1. Trigger the picker\nwinapp ui invoke \"BtnOpenFile\" -a $AppPid\n\n# 2. Find the picker window (it's a dialog owned by the app window)\nStart-Sleep 1\n$allWindows = winapp ui list-windows -a $AppPid --json 2>$null | ConvertFrom-Json\n$picker = $allWindows | Where-Object { $_.title -match \"Open|Save\" }\n$pickerHwnd = $picker.hwnd\n\n# 3. Interact with the picker using -w \u003CHWND>\n#    Type a filename:\nwinapp ui set-value \"FileNameControlHost\" \"test.txt\" -w $pickerHwnd\n#    Click Open\u002FSave:\nwinapp ui invoke \"Open\" -w $pickerHwnd     # or \"Save\", \"Cancel\"\n#    Or cancel:\nwinapp ui invoke \"Cancel\" -w $pickerHwnd\n\n# 4. Verify the app processed the file\nwinapp ui wait-for \"StatusBar\" -a $AppPid -p Name --value \"opened\" -t 3000\n```\n\n**Tip:** Use `winapp ui inspect -w \u003CpickerHwnd> --interactive` to discover the picker's controls — they include the folder tree, file list, filename textbox, and Open\u002FCancel buttons.\n\n### Testing Context Menus and Flyouts\n\nMenuFlyouts and ContextFlyouts are fully testable. They appear in the UI automation tree when open.\n\n```powershell\n# 1. Right-click to open a ContextFlyout\nwinapp ui click \"LstItems\" -a $AppPid --right\nStart-Sleep 0.5\n\n# 2. The flyout MenuItems appear in the tree immediately\n#    Find them with inspect or search:\nwinapp ui inspect -a $AppPid --interactive   # shows MnuCopy, MnuDelete, etc.\n\n# 3. Click a flyout item\nwinapp ui invoke \"MnuCopy\" -a $AppPid\n\n# 4. Verify the action\nwinapp ui wait-for \"StatusText\" -a $AppPid -p Name --value \"Copied\" -t 2000\n```\n\n**For MenuBar flyouts** (File, Edit, View menus):\n```powershell\n# Click the menu header to open\nwinapp ui invoke \"FileMenu\" -a $AppPid\nStart-Sleep 0.5\n# Click the sub-item\nwinapp ui invoke \"MenuSaveAs\" -a $AppPid\n```\n\n### Testing ContentDialogs\n\nContentDialogs are in-app controls (same window) — they appear directly in the UI tree when shown.\n\n```powershell\n# 1. Trigger the dialog\nwinapp ui invoke \"BtnDelete\" -a $AppPid\nStart-Sleep 0.5\n\n# 2. The dialog buttons appear in the tree\n#    For a standard confirmation dialog:\nwinapp ui search \"Primary\" -a $AppPid --json   # finds the primary button\nwinapp ui invoke \"Primary\" -a $AppPid           # click \"Yes\"\u002F\"Delete\"\u002F\"Save\"\n#    Or:\nwinapp ui invoke \"Secondary\" -a $AppPid         # click \"No\"\u002F\"Don't Save\"\nwinapp ui invoke \"Close\" -a $AppPid             # click \"Cancel\"\n\n# 3. Wait for dialog to dismiss\nwinapp ui wait-for \"Primary\" -a $AppPid --gone -t 3000\n```\n\n**Tip:** ContentDialog buttons often don't have custom AutomationIds — use `inspect` to find the actual selector (slug or text match).\n\n### Advanced Input: keyboard, hover, drag, touch & pen\n\nSynthetic input beyond `invoke`\u002F`click`\u002F`set-value`. Each verb takes `-a \u003CPID>` \u002F `-w \u003CHWND>` like the rest.\n\n**`send-keys` — real keyboard input.** Named keys (`enter`, `tab`, `f5`), combos (`ctrl+shift+t`), raw `vk=0x42`, or literal text. `--via` selects the transport:\n- `post-message` (default) — HWND-targeted, no foreground needed; raises `TextChanged` but **not** per-character `KeyDown`.\n- `send-input` — OS-wide; real per-character `KeyDown` + `TextChanged`. **Required for accelerators\u002Fshortcuts** (`KeyboardAccelerator`, e.g. `ctrl+t`) and for reliable typing into a WinUI 3 \u002F WPF `TextBox`.\n\n```powershell\nwinapp ui send-keys \"ctrl+s\" -a $AppPid --via send-input                          # fire a Ctrl+S accelerator\nwinapp ui send-keys \"hello world\" --target \"TxtName\" -a $AppPid --via send-input  # focus then type\nwinapp ui send-keys --verbatim \"down down enter\" -a $AppPid                       # type the words, not the keys\n```\n`--target` focuses first; `text=\u003Cliteral>` \u002F `--verbatim` type literally instead of interpreting key names. System combos (`win+r`, `alt+f4`) need `--allow-system-keys` + `--via send-input` (`win+l` stays blocked).\n\n**`hover` — tooltips, flyouts, hover states.** Dwells on the element (`--dwell-time`, default 800 ms) so hover-triggered UI appears in the tree.\n```powershell\nwinapp ui hover \"BtnInfo\" -a $AppPid\nwinapp ui wait-for \"InfoTooltip\" -a $AppPid -t 2000\n```\n\n**`drag` — drag-drop, reorder, resize, sliders.** `\u003Cfrom>`\u002F`\u003Cto>` are each an element selector (its center) or screen `x,y` from `inspect`. `--hold-ms` long-presses before moving; `--dwell-ms` settles on the target before releasing (merge\u002Flatch targets).\n```powershell\nwinapp ui drag \"ItemA\" \"ItemB\" -a $AppPid          # reorder ItemA onto ItemB\nwinapp ui drag \"SldVolume\" 300,120 -a $AppPid      # drag a slider thumb to a point\n```\n\n**`touch` — touch gestures.** `-g`: `tap` (default), `double-tap`, `long-press`, `swipe`, `pinch`, `stretch`; `--direction`\u002F`--distance`\u002F`--to-point` for swipes, `--fingers` for multi-touch. Needs an unlocked interactive desktop with the window foregroundable.\n```powershell\nwinapp ui touch \"LstFeed\" -g swipe --direction up --distance 400 -a $AppPid\nwinapp ui touch \"ImgPhoto\" -g stretch --distance 200 -a $AppPid    # pinch-to-zoom\n```\n\n**`pen` — pen\u002Fstylus.** Taps or draws ink; `--path \"x,y x,y …\"` for a multi-point stroke, with `--pressure`, `--tilt-x`\u002F`--tilt-y`, `--eraser` (Win10 1809+).\n```powershell\nwinapp ui pen \"InkCanvas\" --path \"50,50 120,80 200,60\" --pressure 0.8 -a $AppPid\nwinapp ui pen \"InkCanvas\" --path \"50,50 200,60\" --eraser -a $AppPid\n```\n\n### Recording a Video\n\n`winapp ui record` captures the target window (or an element region) to an H.264 MP4 — handy for a repro clip of a flow or animation. Records until stopped (newline\u002FEOF on stdin, or Ctrl+C); `--duration-sec N` gives a fixed-length clip (simplest for scripts). The MP4 is finalized on graceful stop.\n\n```powershell\nwinapp ui record -a $AppPid --duration-sec 6 --fps 30 -o \"flow.mp4\"\n```\n`--max-edge N` downscales large windows; `--capture-screen` uses screen BitBlt to include popups\u002Foverlays outside the target window (also on `screenshot`).\n\n### Key Gotchas\n\n- **`set-value` does NOT commit default TextBox bindings** — WinUI 3 `x:Bind TwoWay` on TextBox.Text updates the ViewModel on `LostFocus` by default. UIA `set-value` changes the text but doesn't trigger focus events. **Fix:** apps should use `UpdateSourceTrigger=PropertyChanged` on TextBox bindings (see design skill). If the app doesn't, `invoke` a button or `click`\u002F`focus` another element after `set-value` to trigger `LostFocus`.\n- **Set a `RichEditBox` with `send-keys`, not `set-value`** — WinUI 3 `RichEditBox` \u002F WPF `RichTextBox` don't support UIA value-setting. `focus` (or `--target`), then `send-keys \"…\" --via send-input` — which also raises real per-key `KeyDown`, so use it whenever a control reacts to individual keystrokes (or a `KeyboardAccelerator`) rather than a bulk value change.\n- **Verify persistence via the data file, not UI relaunch** — killing and relaunching a packaged app from a test script is fragile (MSIX registration timing, PID issues). Instead, check the data file on disk: `Get-Content $dataFile | ConvertFrom-Json` and verify expected values.\n- **Use `$AppPid` not `$Pid`** — `$Pid` is a read-only automatic variable in PowerShell\n- **Use `--value` without `-p`** — it auto-detects the right UIA pattern (TextPattern → ValuePattern → TogglePattern → SelectionPattern → Name). Only use `-p PropertyName --value` when you need a specific property like `IsEnabled`\n- **File pickers need `-w \u003CHWND>`** — they run in a separate PickerHost process, so `-a PID` won't find them. Use `list-windows` to discover the picker HWND first\n- **Flyouts need a short `Start-Sleep`** after triggering — the menu items appear in the tree asynchronously\n\n",{"name":5,"description":7},"main","e24b64bdac040ad169ed16b14853eff1b20cd726","skills_archive\u002Fmerged-into-parent\u002Fwinui-ui-testing",0,"https:\u002F\u002Fgithub.com\u002FBumpyClock\u002Fagent-templates","https:\u002F\u002Fgithub.com\u002FBumpyClock","2026-11-14 03:12:06",{"source":8,"skillName":5,"commands":32,"prompt":42,"zipAvailable":43},[33,36,39],{"tool":34,"command":35},"npx","npx skills add BumpyClock\u002Fagent-templates --skill winui-ui-testing",{"tool":37,"command":38},"bunx","bunx skills add BumpyClock\u002Fagent-templates --skill winui-ui-testing",{"tool":40,"command":41},"pnpm","pnpm dlx skills add BumpyClock\u002Fagent-templates --skill winui-ui-testing","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FBumpyClock\u002Fagent-templates\u002Fblob\u002Fmain\u002Fskills_archive\u002Fmerged-into-parent\u002Fwinui-ui-testing\u002FSKILL.md",true,[],[46,53,60,67,74,81],{"skillNo":47,"name":48,"nameZh":6,"description":49,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":50,"categories":51,"keywords":52,"publishedAt":19},"01M79FEE6E257MWVEBY43X0NVN","writing-plans","Use when you have a spec or requirements for a multi-step task, before touching code","https:\u002F\u002Fgithub.com\u002FBumpyClock\u002Fagent-templates\u002Fblob\u002Fmain\u002Fskills_archive\u002Fwriting-plans\u002FSKILL.md",[],[],{"skillNo":54,"name":55,"nameZh":6,"description":56,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":57,"categories":58,"keywords":59,"publishedAt":19},"01M79FEB8GTJC6ZHDK67T40R20","workflow-from-chats","Extract preferences from agent chats → skills, rules, workflow docs. For learning preferences, mining feedback, personalizing workflows.","https:\u002F\u002Fgithub.com\u002FBumpyClock\u002Fagent-templates\u002Fblob\u002Fmain\u002Fskills_archive\u002Fworkflow-from-chats\u002FSKILL.md",[],[],{"skillNo":61,"name":62,"nameZh":6,"description":63,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":64,"categories":65,"keywords":66,"publishedAt":19},"01M79FE7TMNGVZZ0M8NV4N0X6N","winui3-csharp-app","WinUI 3 \u002F Windows App SDK desktop apps in C#\u002FXAML. MVVM, bindings, navigation, Mica\u002FAcrylic, windowing, packaging, performance.","https:\u002F\u002Fgithub.com\u002FBumpyClock\u002Fagent-templates\u002Fblob\u002Fmain\u002Fskills_archive\u002Fwinui3-csharp-app\u002FSKILL.md",[],[],{"skillNo":68,"name":69,"nameZh":6,"description":70,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":71,"categories":72,"keywords":73,"publishedAt":19},"01M79FE31HY46BHN67CQGB7MVJ","why","Use for 'why does X work this way', 'why we picked Y', design rationale, regressions, postmortems, or data-backed thresholds. Discovers available MCPs and queries each evidence category (source control, issue tracker, long-form docs, real-time chat, infrastructure observability, error tracking, product analytics warehouse) in parallel, then returns a cited read on decisions and tradeoffs. Use how for runtime behavior.","https:\u002F\u002Fgithub.com\u002FBumpyClock\u002Fagent-templates\u002Fblob\u002Fmain\u002Fskills_archive\u002Fwhy\u002FSKILL.md",[],[],{"skillNo":75,"name":76,"nameZh":6,"description":77,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":78,"categories":79,"keywords":80,"publishedAt":19},"01M79FE0N7MGWDG8SCD60FWTV5","what-did-i-get-done","Summarize authored commits over a user-specified time period into a concise status update.","https:\u002F\u002Fgithub.com\u002FBumpyClock\u002Fagent-templates\u002Fblob\u002Fmain\u002Fskills_archive\u002Fwhat-did-i-get-done\u002FSKILL.md",[],[],{"skillNo":82,"name":83,"nameZh":6,"description":84,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":85,"categories":86,"keywords":87,"publishedAt":19},"01M79FDYBJG9QNCQC0MMVBDT80","weekly-review","Produce a short weekly synthesis of authored commits with highlights by bugfix, tech debt, and net-new work.","https:\u002F\u002Fgithub.com\u002FBumpyClock\u002Fagent-templates\u002Fblob\u002Fmain\u002Fskills_archive\u002Fweekly-review\u002FSKILL.md",[],[]]