How can I repeatedly take a screenshot of a specific area in OS X?
You can use the screencapture
command line utility. It includes (amongst others) the following options:
-x do not play sounds
-R<x,y,w,h> capture screen rect
files where to save the screen capture, 1 file per screen
So, in your case, to grab a screenshot with the top left corner at 20/20, creating a 640x380 window:
screencapture -x -R20,20,640,380 ~/Desktop/test.png
You could put this command into your crontab
to have it execute repeatedly, or simply use a loop that runs in a Terminal window. In that case, we will create a screenshot every second (sleep 1
), and the output file will be named screen_YYMMDDTHHMMSS
accordingly.
while [ 1 ]; do
date=$(date "+%Y%m%dT%H%M%S")
screencapture -x -R20,20,640,380 ~/Desktop/"screen_${date}.png"
sleep 1
done
You could also create an Automator action or AppleScript to run a shell script like the above. For example, open Script Editor, then paste this:
do shell script "date=$(date '+%Y%m%dT%H%M%S'); screencapture -x -R20,20,640,380 ~/Desktop/screen_${date}.png"
It should look like this:
Save that script and use FastScripts to easily assign a keyboard shortcut.
If you are open to using an app/utility, I would highly recommend Skitch:
https://evernote.com/skitch/
It has a shortcut for "Previous Snapshot Area."
(In addition you can capture a selection using a timer, capture the whole screen, just a window, or just a menu.)
It's free and has a ton of features including editing / annotations, quick and easy sharing, etc.