Agent skill · daymade

capture-screen

Programmatic screenshot capture on macOS. Find window IDs with Swift CGWindowListCopyWindowInfo, control application windows via AppleScript (zoom, scroll, select), and capture with screencapture. Use when automating screenshots, capturing application windows for documentation, or building multi-shot visual workflows.

What it needs

About 5k tokens when loaded.

What this skill does

Capture Screen Programmatic screenshot capture on macOS: find windows, control views, capture images. Quick Start Overview Three-step workflow: Step 1: Get Window ID (Swift) Use Swift with CoreGraphics to enumerate windows. This is the only reliable method on macOS. Quick inline execution Using the bundled script Output format: WID=12345 App=Microsoft Excel Title=workbook.xlsx Parse the WID number for use with screencapture -l. Step 2: Control Window (AppleScript) Verified commands for controlling application windows before capture. Microsoft Excel (full AppleScript support) Any application (basic control) Timing and Timeout Always add sleep 1 after AppleScript commands before capturing, to allow UI rendering to complete. IMPORTANT: osascript hangs indefinitely if the target application is not running or not responding. Always wrap with timeout: Step 3: Capture (screencapture) Retina displays On Retina Macs, screencapture outputs 2x resolution by default (e.g., a 2032x1238 window produces a 4064x2476 PNG). This is normal. To get 1x resolution, resize after capture: Verify capture Multi-Shot Workflow Complete example: capture multiple sections of an Excel workbook. Failed Approaches (DO NOT USE) These methods were tested and confirmed to fail on macOS: Method Error Why It Fails -------- ------- ------------- System Events → id of window Error -1728 System Events cannot access window IDs in the format screencapture needs Python import Quartz (PyObjC) ModuleNotFoundError PyObjC not installed in system Python; don't attempt to install it — use Swift instead osascript window id Wrong format Returns AppleScript window index, not CGWindowID needed by screencapture -l Permission Troubleshooting swift scripts/getwindowid.swift reads on-screen windows via CoreGraphics, so it needs Screen Recording permission on macOS. Use this order: 1. Confirm trigger 2. Confirm target identity 3. …

How to use it

Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:

@skills daymade/capture-screen--933d34

View the source on GitHub

Browse the @skills marketplace