When I used to work on a Linux system, there was a utility we had that would let me take screen captures every 30 seconds while my computer was otherwise unattended, as a way to see if anyone else was using it or not. I liked it. Now I’d like to do the same on my Mac system. Possible?
Well, Mr. Bond, it sounds like some good spy software for a computer in the SMERSH offices, but perhaps that’s not your intention. Still, it opens up a bit of a can of worms if you are letting others use your computer while you’re running any sort of spyware or monitoring software that actually tracks and stores their action.
That’s not exactly what you’re asking me, but it’s not hard to subvert the script I’ll share for that purpose. Then again, guns don’t kill people, bullets do. Um. Nevermind.
Anyway, yes, if you are willing to write a short shell script that you’d run in Mac’s Terminal application, it’s quite doable.
The key is a program called screencapture.
To see how to use it, you can simply type its name into Terminal directly with “–help”:
$ screencapture --help 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 -timage 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 -a do not include windows attached to selected windows -l capture this windowsid files where to save the screen capture, 1 file per screen
That’s a lot of data to absorb. The key flags are “-tfmt” to specify the output format and “-x” to disable the screen capture sound. You can add a time delay, but we’ll do that with a looping structure in the shell itself so that it’s reinvoked every “n” seconds.
Kind of like this:
while true ; do sleep 30 screencapture -tpng -x capture.$(date +%F-%T).png done
There are more graceful ways to come up with an incrementing filename, but we’re just using date and time so that a typical resultant filename might be capture.2012-04-15-16:24:25.png.
Want to take a screen cap every 15 second or five minutes? Just change the sleep variable.
To use this, simply type the above into the Terminal — I recommend moving into a new subdirectory first so that the screencaps don’t take over the Desktop — then minimize the Terminal window and walk away. As long as they don’t kill the shell, it’ll diligently keep taking a screen capture every “n” seconds until you either run out of disk space (not good) or kill it.
Done capturing? Just open up the Terminal window again and press Ctrl-C.
Now, use this wisely and appropriately, please.