---
name: windows-screen-recorder
description: >
Record a cropped region of the Windows desktop to a clean MP4 video file.
Drag a box over any part of the screen, record, and stop with one click.
Uses FFmpeg (gdigrab) with a drag-to-crop overlay. Use when the user says
"screen record", "record my screen", "record a region", "录屏", "录制屏幕",
"录制桌面", "录制操作演示", or "make a screen recording".
---
# Windows Screen Recorder: Cropped Desktop Capture
You generate and run a small PowerShell tool that records a user-selected rectangle of the Windows desktop to an MP4. Headline feature: a drag-to-crop overlay — the user drags a box over any part of the screen, records, then clicks "Stop and Save" to get a valid, seekable video.
**Windows only**, needs **FFmpeg on PATH**. v1 records video only (silent). Microphone/system-audio add-ons are documented at the bottom.
## Step 1: Confirm the environment
1. Check OS is Windows. If not, tell the user this is Windows-only and stop.
2. Check FFmpeg: run `ffmpeg -version`. If missing, tell user to install and reopen terminal:
- `winget install Gyan.FFmpeg` (or download from https://ffmpeg.org/download.html)
## Step 2: Ask what they want (only if unclear)
- **Region**: drag-to-crop (default), full screen, or exact `x,y,w,h`?
- **Frame rate**: default 30 fps. 60 for fast motion, 15 for smaller files.
- **Save to**: default `.\recordings\`.
If they just say "record my screen", use the default: drag-to-crop, 30 fps, `.\recordings\`.
## Step 3: Run the bundled script
The recorder is bundled at `scripts/record-screen.ps1` inside this skill folder.
Resolve it via `CLAUDE_SKILL_DIR` if set, else `~/.workbuddy/skills/windows-screen-recorder/scripts/record-screen.ps1`.
```powershell
powershell -ExecutionPolicy Bypass -File "<path-to-record-screen.ps1>" # drag-to-crop
powershell -ExecutionPolicy Bypass -File "<path-to-record-screen.ps1>" -FullScreen
powershell -ExecutionPolicy Bypass -File "<path-to-record-screen.ps1>" -Region "200,150,1280,720" -Fps 60 -Name my-demo
```
Example resolution (PowerShell):
```powershell
$dir = $env:CLAUDE_SKILL_DIR; if (-not $dir) { $dir = "$env:USERPROFILE\.workbuddy\skills\windows-screen-recorder" }
$ps1 = Join-Path $dir "scripts\record-screen.ps1"
```
## Step 4: Report to the user
Explain: a dimmed overlay appears → drag a box over what to capture → a small "Stop and Save" button appears top-right → clicking it writes the MP4 to `.\recordings\`. Report the saved file path back.
## Rules
- **Never kill the FFmpeg process to stop.** Always send `q` to stdin and wait; killing leaves the MP4 without a moov atom (unplayable). The script already handles graceful stop.
- Width/height are rounded down to **even numbers** (H.264 yuv420p rejects odd dimensions).
- **DPI awareness is set before any window** so the selected box lines up with the recording under display scaling (125%/150%).
- Default to silent. Do not add audio inputs unless the user asks.
- Save into `.\recordings\` (or `-OutDir`) with a timestamped name; never overwrite.
- The floating Stop button gets captured if it sits inside the recorded region — place it away from the capture area or warn the user.
## Notes and limits
- Windows only (v1). Multi-monitor picker spans all screens; single/primary-monitor capture is the reliable path.
- Performance: `libx264 -preset veryfast` default; pass `-Encoder h264_nvenc` on NVIDIA GPUs to offload encoding.
- Audio add-ons (not in v1):
- Microphone / voiceover: append `-f dshow -i audio="<device name>"` (list devices with `ffmpeg -list_devices true -f dshow -i dummy`).
- System audio: needs a virtual audio device (enable "Stereo Mix" in Sound settings, or install VB-Audio Cable) — Windows does not expose desktop-audio loopback to FFmpeg by default.