{"slug": "show-hn-sightline-windows-cli-for-ai-agents-to-capture-ui-and-map-dpi-coords", "title": "Show HN: Sightline – Windows CLI for AI agents to capture UI and map DPI coords", "summary": "A developer released Sightline, a Windows command-line tool that gives AI coding agents a read-only way to observe desktop applications, distributed as a single executable invoked with the command `sight`. Sightline finds windows, screenshots them even when covered, waits for UI pixels to change and then settle, and returns a `formula` mapping image pixels to screen, window and client coordinates, with per-monitor DPI awareness reporting `dpi_scale` and `monitor_dpi_scale`. The tool only observes — it never clicks, types or moves the mouse — and returns image file paths rather than base64 so a screenshot costs one file read instead of thousands of tokens.", "body_md": "Eyes and a stopwatch for AI coding agents on Windows. One small exe, command `sight`.\n\nsightline finds windows, screenshots them even when covered, waits for the UI to change and then stop\nchanging, and tells the agent how image pixels map to screen, window and client coordinates. It also\nmeasures CPU and memory of a whole process tree. It **only observes**: it never clicks, types or\nmoves the mouse. The agent acts with its own tools, then uses sightline to check the result.\n\n[Why](#why-sightline) • [Install](#install) • [Quick start](#quick-start) • [Use with agents](#use-it-with-ai-agents) • [Reference](https://github.com/sao-coding/sightline/blob/main/docs/REFERENCE.md) • [FAQ](#faq)\n\n```\nsight list --exe notepad                  # which window?\nsight shot --hwnd 15603054 --settle 300   # what does it look like, once it is stable?\nsight wait --hwnd 15603054 --change --settle 300   # after my click: has the UI changed and settled?\nsight stat --pid 19668 --duration 2000    # how much CPU and RAM?\n```\n\nAsked to \"check the dialog looks right\", an agent on Windows usually writes a throwaway\nPowerShell script: `Start-Sleep 3`, `CopyFromScreen`, a hard-coded PID. sightline replaces that.\n\n| The throwaway script | What goes wrong | sightline | \n|---|---|---|\n| `Start-Sleep 3` | Too short is flaky, too long is slow | `--settle 300` waits until pixels stop changing, with a timeout and an honest`settled:false` | \n| `Start-Sleep 0.5` after a click | The UI may not have started changing yet, so a plain settle returns the old frame | `--expect-change` waits for pixels to differ from a baseline first, then settles | \n| `CopyFromScreen` | Whatever is on top ends up in the image | `shot --hwnd` captures the window itself, even when covered | \n| Window capture APIs | Right-click menus are separate windows and get missed | The app's own popups are detected and included | \n| The model resizes the image | Pixel positions no longer match the screen | Every shot returns a `formula` from image px to screen px | \n| Hand-cut `Crop` , window moved to a fixed spot first | Breaks when the window is somewhere else | `--crop x,y,w,h` is window-relative and position-independent;`formula_window` and`formula_client` map pixels to window and client coordinates | \n| 150% DPI scaling | Hand-made coordinate math breaks | Per-Monitor DPI aware; reports `dpi_scale` and`monitor_dpi_scale` | \n| `Get-Process` | One process, hard-coded PID | `list` finds the PID;`stat` covers the whole tree with avg / p95 / max | \n| Free-form text | The agent parses prose and guesses what failed | One JSON line, stable error codes, and a `hint` naming the next step | \n\nImages are written to a file and only the **path** is returned, never base64, so a screenshot\ncosts one file read instead of thousands of tokens.\n\n| Command | Answers | Notes | \n|---|---|---|\n| `list` | Which windows exist, and which PID / HWND do I target? | Rect, monitor, DPI, minimized state; noisy windows hidden by default | \n| `shot` | What does this window look like now? | Covered windows, popups, change and settle wait, window-relative `--crop` , coordinate formulas | \n| `wait` | Has the UI changed and settled after my action? | Same waiting as `shot` , no image;`changed` ,`change_ms` ,`settled` | \n| `rec` | Show me what happened: an animated GIF | Window, crop or region to GIF; merges identical frames; `--until-settled` ,`--keyframes` stills | \n| `stat` | How much CPU and RAM over time? | Whole process tree (Electron, browsers, games); private bytes | \n| `doctor` | What monitors and DPI scales does this machine have? | First stop when something looks off | \n\n**PowerShell one-liner** (installs to `%LOCALAPPDATA%\\Programs\\sight` and adds it to your user `PATH`):\n\n```\nirm https://raw.githubusercontent.com/sao-coding/sightline/main/install.ps1 | iex\n```\n\nOpen a **new terminal** afterwards so the `PATH` change is picked up, then check with `sight doctor`.\nPin a version, change the folder, or uninstall:\n\n```\n$env:SIGHT_VERSION = \"0.1.0\"; irm https://raw.githubusercontent.com/sao-coding/sightline/main/install.ps1 | iex\n$env:SIGHT_INSTALL_DIR = 'D:\\tools\\sight'; irm https://raw.githubusercontent.com/sao-coding/sightline/main/install.ps1 | iex\n$env:SIGHT_UNINSTALL = 1; irm https://raw.githubusercontent.com/sao-coding/sightline/main/install.ps1 | iex\n```\n\nThe script verifies the download against the `sight.exe.sha256` published with each release.\n\n**Manual.** Download `sight.exe` from [Releases](https://github.com/sao-coding/sightline/releases) (`sight-windows-x64.zip` also holds the\ndocs and the skill), put it in a folder, and add that folder to `PATH`:\n\n```\n# example: C:\\tools\\sight (user PATH, no admin needed)\n[Environment]::SetEnvironmentVariable('Path', \"$([Environment]::GetEnvironmentVariable('Path','User'));C:\\tools\\sight\", 'User')\n```\n\nOr via Settings → System → About → Advanced system settings → Environment Variables → `Path` → New.\nRestart the terminal (and the agent) afterwards. Agents must be able to find `sight` on their `PATH`.\n\n**From source** (Windows 10/11, Rust toolchain):\n\n```\ncargo build --release     # target\\release\\sight.exe\nsight doctor                              # monitors and DPI\nsight list --exe notepad                  # find the target\nsight shot --hwnd 15603054 --settle 300   # capture it once stable\n```\n\nOne turn of the agent loop:\n\n1. \n**Find the target.**\n\n```\n> sight list --exe notepad\n{\"v\":1,\"ok\":true,\"data\":{\"count\":1,\"windows\":[{\"hwnd\":15603054,\"pid\":19668,\"exe\":\"Notepad.exe\",\"title\":\"Untitled - Notepad\",\"rect\":{\"x\":3010,\"y\":362,\"w\":1178,\"h\":637},\"monitor\":1,\"dpi_scale\":1.0,\"monitor_dpi_scale\":1.0,\"minimized\":false}]},\"warnings\":[]}\n```\n\n2. \n**Look.** Open`data.path` with the agent's image viewer.\n\n```\n> sight shot --hwnd 15603054 --settle 300\n{\"v\":1,\"ok\":true,\"data\":{\"path\":\"C:\\\\Users\\\\me\\\\AppData\\\\Local\\\\Temp\\\\sightline\\\\shot-20261123-214402-405.jpg\",\"image\":{\"w\":1178,\"h\":637},\"maps_to\":{\"space\":\"screen_physical\",\"x\":3010,\"y\":362,\"w\":1178,\"h\":637},\"scale\":1.0,\"formula\":\"screen_x = 3010 + px / 1.0; screen_y = 362 + py / 1.0\",\"settled\":true,\"elapsed_ms\":945,\"popups\":[]},\"warnings\":[]}\n```\n\n3. \n**Act** with the agent's own input tool, at coordinates computed from the formulas below.\n4. \n**Wait for the UI** , then look. Right after an external click the UI may not have started\nchanging, so a plain`--settle` could return the old frame.`--expect-change` (or`wait --change` ) first waits for pixels to differ from a baseline, then settles. Both phases share`--timeout` :\n\n```\n> sight wait --hwnd 15603054 --change --settle 300\n{\"v\":1,\"ok\":true,\"data\":{\"changed\":true,\"change_ms\":326,\"settled\":true,\"elapsed_ms\":492},\"warnings\":[]}\n> sight shot --hwnd 15603054 --expect-change --settle 300     # same wait, then saves the image\n```\n\n If nothing changes before the timeout, `shot` still saves the latest frame and both commands\nfail with`TIMEOUT` (exit 5) and`data.changed:false` . Tiny noise such as a blinking caret does\nnot count: a change needs`--min-change-px` differing pixels (default 16). The baseline is the\nfirst captured frame, which arrives about 0.3 s after`sight` starts, so a change that already\nfinished by then is not seen (`TIMEOUT` ,`changed:false` : take a plain`shot` and look).**Instant reactions: `--baseline`.** Take a shot*before* acting and wait against it, so a change\nthat finishes before`sight` even starts is still detected:\n\n```\n> sight shot --hwnd 15603054 --out before.png\n# act with your own tool; the UI reacts instantly\n> sight wait --hwnd 15603054 --baseline before.png --settle 300\n{\"v\":1,\"ok\":true,\"data\":{\"changed\":true,\"change_ms\":318,\"settled\":true,\"elapsed_ms\":502},\"warnings\":[]}\n```\n\n The same order with `wait --change` and no`--baseline` fails with a false`TIMEOUT` . Each shot\nwrites a sidecar`before.sight.json` ; a baseline from another window, with another`--crop` , or\nof another kind (window vs region) is`INVALID_ARGS` , never a silent wrong comparison. A window that\nwas resized or expanded since the baseline counts as a change (`changed:true` , warning`baseline_size_changed` ).\n5. \n**Re-check** with the same`shot` and compare. For performance, run`stat` while the app works:\n\n```\n> sight stat --pid 17400 --duration 2000\n{\"v\":1,\"ok\":true,\"data\":{\"pid\":17400,\"exe\":\"powershell.exe\",\"duration_ms\":2038,\"samples\":4,\"logical_cores\":16,\"cpu_core_pct\":{\"avg\":100.42,\"p95\":104.98,\"max\":104.98},\"cpu_total_pct\":{\"avg\":6.28,\"p95\":6.56,\"max\":6.56},\"mem_mb\":{\"avg\":52.87,\"p95\":52.87,\"max\":52.87},\"processes\":[...]},\"warnings\":[]}\n```\n\n One full core ( `cpu_core_pct` ≈ 100) out of 16 (`cpu_total_pct` ≈ 6.3): a busy loop.\n\n`sight rec` records a window or region for README demos and test evidence. It blocks until it is\ndone, so run it in the background while you act:\n\n``` php\n$job = Start-Job { sight rec --hwnd 123456 --duration 10000 --until-settled 500 --keyframes 3 --out C:\\tmp\\demo.gif }\nStart-Sleep -Milliseconds 700                       # capture needs ~0.3 s to start\n# ... act with your own tool (click, type) ...\n$rec = Receive-Job $job -Wait -AutoRemoveJob | ConvertFrom-Json   # data.path, data.keyframes[].path\n```\n\nThe result has `frames`, `fps`, `duration_ms`, `size_bytes` and the same coordinate formulas as\n`shot`. Identical frames are merged (a static window is one long frame), and `--keyframes 3` also\nsaves PNG stills of the biggest changes so an agent can check the recording without decoding the\nGIF. Defaults: `--fps 10` (max 30), `--max-edge 800`.\n\n`rec` picks one capture source when it starts and never switches: `--source auto` (default) uses\nscreen capture of the window's rect, which includes menus, tooltips and popups, unless another window\ncovers the target, and then window capture (`source`, `source_reason` and the warning\n`rec_window_source_no_popups` say which). `--pad 40` also records 40 px around the window so a\ndropdown that sticks out is included. The capture follows a window that moves; windows covering it\nmid-recording are listed in `occlusion_events`.\n\nFor a window shot, `shot` returns one formula per origin. Use the one that matches the origin of\nyour own input tool, with `px, py` in the saved image:\n\n```\n> sight shot --hwnd 11736012 --crop 100,120,300,200 --max-edge 0\n{\"v\":1,\"ok\":true,\"data\":{\"image\":{\"w\":300,\"h\":200},\"maps_to\":{\"space\":\"screen_physical\",\"x\":307,\"y\":270,\"w\":300,\"h\":200},\"scale\":1.0,\"formula\":\"screen_x = 307 + px / 1.0; screen_y = 270 + py / 1.0\",\"window\":{\"frame\":{\"x\":207,\"y\":150,\"w\":642,\"h\":452},\"client\":{\"x\":208,\"y\":181,\"w\":640,\"h\":420},\"client_offset\":{\"x\":1,\"y\":31}},\"formula_window\":\"win_x = 100 + px / 1.0; win_y = 120 + py / 1.0\",\"formula_client\":\"client_x = 99 + px / 1.0; client_y = 89 + py / 1.0\",\"settled\":true,\"changed\":false,\"change_ms\":null,\"elapsed_ms\":351,\"popups\":[]},\"warnings\":[]}\n```\n\n| Field | Origin | Use it for | \n|---|---|---|\n| `formula` | the screen (virtual desktop), physical px | tools that click at absolute screen coordinates | \n| `formula_window` | top-left of the window's DWM frame | tools relative to the window; same origin as `--crop` | \n| `formula_client` | top-left of the client area, below the title bar | tools relative to the client area | \n\n`window.frame` and `window.client` are in screen px; `client_offset` is the client top-left minus\nthe frame top-left. Image point (50, 40) above is screen (357, 310), window (150, 160), client\n(149, 129).\n\n`--crop x,y,w,h` is relative to the window frame, so it selects the same part of the window\nwherever the window is. It is applied before `--scale` and `--max-edge`; `--max-edge 0` disables\ndownscaling, so `--crop ... --max-edge 0` is exactly w×h pixels. It works with `--hwnd` and `--pid`\n(not `--region`), and `wait` accepts it too.\n\n- \n**[AGENTS.md](https://github.com/sao-coding/sightline/blob/main/AGENTS.md)** is a one-page brief: commands, the observe loop, the coordinate\nformula, and what to do for each error code. Codex, Cursor and others read it automatically in\nthis repo; copy it, or link to it, from your own project's instructions.\n- \n**`skills/sightline/SKILL.md`** is the same guidance as an Agent Skill, loaded only when needed.\nFor Claude Code:\n\n```\nxcopy /E /I skills\\sightline %USERPROFILE%\\.claude\\skills\\sightline\n```\n\nMake sure `sight` is on the agent's `PATH` (see [Install](#install)).\n\nFull flags and output fields for every command, the coordinate and DPI rules, popup handling, the\noutput contract and the error codes are in **[docs/REFERENCE.md](https://github.com/sao-coding/sightline/blob/main/docs/REFERENCE.md)**.\n\n**Which Windows versions work?** Windows 10 and 11.\n\n**Does anything leave my machine?** No. There is no network code; images stay in a local file.\n\n**Why don't `stat` numbers match Task Manager?** Memory is *private bytes* (commit), not\nTask Manager's \"private working set\".\n\n```\ncargo build --release --locked\ncargo test\n```\n\n- `--expect-change` /`wait --change` baseline on the first captured frame (about 0.3 s after\nstart), so a change that finished earlier is not detected; use`--baseline` for that.\n- The window formulas and `--crop` were only verified on 100% DPI monitors; they are plain physical-px\narithmetic, but not tested at 125% or 150%.\n- `WINDOW_PROTECTED` is untested against a real capture-protected window.\n- Classic Win32 `#32768` menus are untested, so their popup fallback is unverified.\n- The PID-reuse check uses process start time at 1-second resolution, so a PID reused within the same second is not detected.", "url": "https://wpnews.pro/news/show-hn-sightline-windows-cli-for-ai-agents-to-capture-ui-and-map-dpi-coords", "canonical_source": "https://github.com/sao-coding/sightline", "published_at": "2026-11-25 06:08:51+00:00", "updated_at": "2026-11-25 06:45:26.446435+00:00", "lang": "en", "topics": ["ai-agents", "ai-tools", "developer-tools", "computer-vision"], "entities": ["Sightline", "sao-coding", "Windows", "PowerShell"], "also_reported_by": [], "takeaway": "Sightline replaces throwaway PowerShell screenshot scripts with `sight shot --hwnd` for covered-window capture, `--settle 300` to wait until pixels stop changing (returning `settled:false` on timeout), and a per-shot `formula` mapping image pixels to screen, window and client coordinates under per-m", "recommendation": null, "alternates": {"html": "https://wpnews.pro/news/show-hn-sightline-windows-cli-for-ai-agents-to-capture-ui-and-map-dpi-coords", "markdown": "https://wpnews.pro/news/show-hn-sightline-windows-cli-for-ai-agents-to-capture-ui-and-map-dpi-coords.md", "text": "https://wpnews.pro/news/show-hn-sightline-windows-cli-for-ai-agents-to-capture-ui-and-map-dpi-coords.txt", "jsonld": "https://wpnews.pro/news/show-hn-sightline-windows-cli-for-ai-agents-to-capture-ui-and-map-dpi-coords.jsonld"}}