Monday, January 25, 2010

Taking Screenshots from Mac Terminal Session

Sometimes, it can be very useful to take screenshots in command line to be used when scripting.  You can use  screencapture to capture and manipulate clipboard contents.

The syntax is   screencapture [ -SWCTMPcimswxt ] file

Option
Option Description
-c
Force screen capture to go to the clipboard.
-C
Capture the cursor as well as the screen. Only allowed in non-interactive modes.
-i
Capture screen interactively, by selection or window. The control key will cause the screen shot to go to the clipboard. The space key will toggle between mouse selection and window selection modes. The escape key will cancel the interactive screenshot.
-m
Only capture the main monitor, undefined if -i is set.
-M
Open the taken picture in a new Mail message.
-o
In window capture mode, do not capture the shadow of the window.
-P
Open the taken picture in a Preview window.
-s
Only allow mouse selection mode.
-S
In window capture mode, capture the screen instead of the window.
-t
Image format to create, default is png (other options include pdf, jpg, tiff and other formats).
-T
Take the picture after a delay of , default is 5.
-w
Only allow window selection mode.
-W
Start interaction in window selection mode.
-x
Do not play sounds.

To take a screenshot of the entire screen and save it to the desktop,
screencapture -S ~/Desktop/screen.jpg

To take a picture of a window, and save it to the desktop;
screencapture -iW ~/Desktop/window.jpg

To take a screenshot of a section of the screen, and save it to the clipboard
screencapture -ic

No comments:

Post a Comment