Programmatic Screen Capture
Capture screenshots programmatically on macOS — find window IDs, control application windows via AppleScript, and capture specific windows for documentation and visual workflows.
Manual screenshots break automation and miss the exact window you need. This playbook lets Claude find, control, and capture any macOS window precisely.
Who it's for: technical writers, developers, documentation authors, QA engineers
Example
"Capture the Excel window for my docs" → Claude finds the window ID, positions it, and saves a clean PNG of exactly that window
CLAUDE.md Template
New here? 3-minute setup guide → | Already set up? Copy the template below.
npx ccplaybooks add capture-screen# Capture Screen
Programmatic screenshot capture on macOS: find windows, control views, capture images.
## Quick Start
```bash
# Find Excel window ID
swift scripts/get_window_id.swift Excel
# Capture that window (replace 12345 with actual WID)
screencapture -x -l 12345 output.pngGet new playbooks like this one
One email a week with new Claude Code workflows. Free, like everything here.
No spam. Unsubscribe anytime.
What This Does
Capture screenshots programmatically on macOS — find window IDs, control application windows via AppleScript, and capture specific windows for documentation and visual workflows.
What's Inside
The template covers:
- Step 1: Get Window ID (Swift)
- Step 2: Control Window (AppleScript)
- Step 3: Capture (screencapture)
- Multi-Shot Workflow
- Failed Approaches (DO NOT USE)
- Permission Troubleshooting
Quick Start
Step 1: Create a Project Folder
Make a dedicated folder for this workflow and open it in Claude Code.
Step 2: Download the Template
Click Download above to save the template, then drop it into your project as CLAUDE.md (or paste it into your existing one).
Step 3: Start Working
Tell Claude what you need in plain language — it will follow the template's workflow automatically. For example:
Capture the Excel window for my docs
Claude reads the template and runs the steps for you.