Command命令
执行以下命令,然后使用相机图标点击任意窗口,就可以截取选中的窗口并保存图片到指定位置:
screencapture -iW ~/Desktop/screen.jpg
而使用以下命令,则可以截取整个屏幕:
screencapture -S ~/Desktop/screen.jpg
以下命令则可以截取部分屏幕,并将图片放入剪贴板:
screencapture -ic
利用-t选项,可以设置图片格式;而-x选项,则可以关闭截图时发出的声音:
screencapture -iW -ttiff ~/Desktop/screen.tiff
如果你希望在截取屏幕后立刻查看图片,那么可以编写一个简短的AppleScript来自动化这个过程。首先屏幕截图,然后使用Preview程序来显示图片。
运行Applications中Utilities目录下的AppleScriptEditor,并输入以下代码:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
do shell script | |
"DATE=`date '+%Y%d%m-%H%M%S'`; | |
FILE=~/Pictures/screenshot-${DATE}.png; | |
screencapture -i -W -x $FILE; | |
if [ -e $FILE ]; | |
then open /Applications/Preview.app $FILE; | |
fi" |
将以上脚本保存到~/Library/Scripts目录,并设置为应用程序。
在AppleScriptEditor的“偏好设置”中,选择“在菜单栏中显示脚本菜单”。
从菜单栏里的脚本图标调用程序,就将在屏幕上显示相机图标,你可以用它点击并截取窗口;也可以点击空格键,将显示十字图标,用以截取鼠标拖拽的屏幕区域。
没有评论:
发表评论