MoonPoint Support Logo

 

Shop Amazon Warehouse Deals - Deep Discounts on Open-box and Used ProductsAmazon Warehouse Deals



Advanced Search
July
Sun Mon Tue Wed Thu Fri Sat
     
14
 
2015
Months
Jul


Tue, Jul 14, 2015 10:40 pm

Screencapture command on Os X

You can take a screen shot from a command line interface (CLI) on a Mac OS X system by using the screencapture command. The screen capture program is located in /usr/sbin. You can see the available options by using screencapture -h; the -h option isn't a valid option for the application, but it will cause the app to print the options it does accept.

$ which screencapture
/usr/sbin/screencapture
$ screencapture -h
screencapture: illegal option -- h
usage: screencapture [-icMPmwsWxSCUtoa] [files]
  -c         force screen capture to go to the clipboard
  -C         capture the cursor as well as the screen. only in non-interactive modes
  -d         display errors to the user graphically
  -i         capture screen interactively, by selection or window
               control key - causes screen shot to go to clipboard
               space key   - toggle between mouse selection and
                             window selection modes
               escape key  - cancels interactive screen shot
  -m         only capture the main monitor, undefined if -i is set
  -M         screen capture output will go to a new Mail message
  -o         in window capture mode, do not capture the shadow of the window
  -P         screen capture output will open in Preview
  -s         only allow mouse selection mode
  -S         in window capture mode, capture the screen not the window
  -t<format> image format to create, default is png (other options include pdf, jpg, tiff and other formats)
  -T<seconds> Take the picture after a delay of <seconds>, default is 5
  -w         only allow window selection mode
  -W         start interaction in window selection mode
  -x         do not play sounds
  -a         do not include windows attached to selected windows
  -r         do not add dpi meta data to image
  -l<windowid> capture this windowsid
  -R<x,y,w,h> capture screen rect
  files   where to save the screen capture, 1 file per screen
$

By default, a screenshot will be stored in PNG format, but you can select other formats with the -t (lowercase "t") option. You can specify that you want to use PDF, JPG, or TIFF, instead. You can use the -T (uppercase "T") option to specify a delay in seconds between the time the command is issued and the time the screen shot is taken, which gives you the opportunity to switch to another window to have a screenshot taken of it. The advantage of screenshot over the GUI Preview program found in the Applications folder for taking a picture of a window is that with Preview sometimes pulldown menus will disappear from a window when you switch to Preview to take a screen shot. With screencapture, you can issue the command with a delay, the default is 5 seconds, switch to the relevant window, select the menu or other option, and then wait the number of seconds specified for screencapture to capture the contents appearing in that window at that time. E.g., the command below will wait 10 seconds to take a snapshot of what is appearing on a window that is the current one when 10 seconds elapses.

$ screencapture -T 10 grayed.png
libpng warning: zero length keyword
libpng warning: Empty language field in iTXt chunk
$

You won't see any indication that the screen capture occurred, so you need to just wait until the specified time has elapsed before looking for the output file, which will be placed in the current directory from which you issued the command if you didn't specify a path, but only the file name. The "libpng warnings" don't indicate that the screen shot couldn't be taken; the output file specified is a valild PNG file.

[/os/os-x] permanent link

Valid HTML 4.01 Transitional

Privacy Policy   Contact

Blosxom logo