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:
![](../../I/static/images/5486f32a039ce69007864980b28ff622da2d419bf31cacaa473e9643b9f19f0c.png)
Save that script and use FastScripts to easily assign a keyboard shortcut.
Thank you so much for documenting the -R option! Sadly not included in the man page. – Jason Harrison – 2016-10-13T21:55:42.627