用 screencapture -W 截取应用窗口
screencapture -W 进入点击选择模式,点一下窗口即可单独截图;加 -o 可去掉窗口阴影。
运行 `screencapture -W window-shot.png` 后点击目标窗口,即可只截取该窗口(含阴影)。
01命令
命令
$ screencapture -W window-shot.png02作用说明
-W 参数进入与图形界面中 Shift-Cmd-4 加空格相同的点击选窗模式,不需要先查窗口 ID。默认截图带投影边距,加 -o 可得到紧贴窗口边缘的干净截图。如果截出来是空白或失败,请到系统设置 → 隐私与安全性中给终端授予屏幕录制权限。
03风险
!注意: 终端需要屏幕录制权限,否则截图可能空白或被拒绝。
04撤销
✓无需撤销——该命令不会改变持久状态。
05来源
- Take a screenshot on Mac依据: Apple's official instructions for window screenshots, including holding Option while clicking to exclude the shadow.
- screencapture — create a screen snapshot (macOS man page)依据: Documents screencapture -W to start interaction mode and capture a window selected by clicking, with -o to omit the window shadow.
最后验证: 2026-09-17 · 分类: 媒体