screenshot
Capture a screenshot of a window or DOM element.
Bridge
Bridge required only when using --selector. Full window screenshots (--title or --window-id) work without a bridge.
Usage
Options
| Option | Description | Default |
|---|---|---|
-s, --selector <css> |
CSS selector — screenshot just this element (requires bridge) | — |
-t, --title <regex> |
Window title to match — regex; quote titles with spaces (auto-discovered from bridge if omitted) | — |
-w, --window-id <id> |
Platform window id (from list-windows) — overrides --title |
— |
-o, --output <path> |
Output file path | screenshot-<timestamp>.png |
--format <png\|jpg> |
Output format | png |
--max-width <number> |
Resize to max width (preserves aspect ratio) | — |
--json |
Output structured JSON metadata | — |
--port <number> |
Bridge port (auto-discover if omitted) | — |
--token <string> |
Bridge token (auto-discover if omitted) | — |
Examples
Full window screenshot
Screenshot by window id
Get the id from list-windows --json (the windowId field). No shell-quoting risk (ids have no spaces), and it works for windows a title regex can't uniquely or reliably match.
DOM element screenshot
Resized element screenshot
JSON metadata output
{
"path": "/tmp/header.png",
"format": "png",
"size": 45231,
"selector": ".header",
"windowTitle": null,
"windowId": "12345678"
}
JPEG format
How It Works
When --selector is used:
- Bridge evaluates
getBoundingClientRect()for the CSS selector - Bridge reports viewport size (
window.innerWidth/innerHeight) - Platform adapter captures the full window
- Crop region is computed: element rect + decoration offset (title bar, borders)
- ImageMagick crops to the element bounds
- Optional resize with
--max-width
When only --title or --window-id is used, the full window is captured directly without cropping.
Tips
- Use
dom --depth 2first to find the right CSS selector - The
--max-widthflag is useful for keeping screenshots manageable for AI agents - Without
--titleor--window-id, the tool auto-discovers the window title from the bridge viadocument.title - Window id format is platform-specific (X11/macOS/Sway numeric, Hyprland hex
0x…) — always take it fromlist-windowsoutput --window-id(platform/OS window) is unrelated to--window-label(Tauri webview label, a bridge concept)