用 screencapture -R 截取屏幕指定区域
按 x,y,宽,高 静默截取精确矩形区域并保存为文件,适合脚本和批量截图。
运行 screencapture -x -R 100,100,900,600 ~/Desktop/crop.png,即可保存从 (100,100) 开始的 900×600 区域。
01命令
命令
$ screencapture -x -R 100,100,900,600 ~/Desktop/crop.png02作用说明
-R 参数按 x,y,宽,高 的顺序指定矩形,坐标从主显示器左上角算起,因此可以在界面变动后重复截取同一区域,非常适合做前后对比或自动化文档截图。-x 表示不播放快门声,适合在共享环境或脚本中使用。保存格式由文件扩展名决定(.png、.jpg、.tiff 均可)。在视网膜屏幕上,文件按 2 倍像素保存。
03风险
!注意: 首次从终端运行时,macOS 会请求“屏幕录制”权限——请授权给终端应用,否则只能截到空白或桌面壁纸。
04撤销
✓无需撤销——该命令不会改变持久状态。
05来源
- screencapture - Create a screenshot of the display依据: Documents `-x Do not play sounds.` and `-R <x,y,w,h>`: capture a rectangle using format x,y,width,height.
- screencapture(1) man page依据: Man page for screencapture listing `-R<x,y,w,h>` (capture a rectangle at the given coordinates) and `-x` (do not play sounds) among its options.
最后验证: 2026-09-19 · 分类: 媒体