Ask Dave Taylor
  • Facebook
  • Instagram
  • Linkedin
  • Pinterest
  • Twitter
  • YouTube
  • Home
  • YouTube Videos
  • Top Categories
  • Subscribe via Email
  • Ask A Question
  • Meet Dave
  • Home
  • Linux Shell Script Programming
  • Secretly capture screenshots on my Mac?

Secretly capture screenshots on my Mac?

April 16, 2012 / Dave Taylor / Linux Shell Script Programming, Mac & MacOS Help / No Comments

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
-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
-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.

Let’s Stay In Touch!

Never miss a single article, review or tutorial here on AskDaveTaylor, sign up for my fun weekly newsletter!
Name: 
Your email address:*
Please enter all required fields
Correct invalid entries
No spam, ever. Promise. Powered by FeedBlitz
Please choose a color:
Starbucks coffee cup I do have a lot to say, and questions of my own for that matter, but first I'd like to say thank you, Dave, for all your helpful information by buying you a cup of coffee!

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Search

Recent Posts

  • How Can I Enable Emergency Alerts in Spanish on Android?
  • Switch from 24-Hour Time to AM/PM in Ubuntu Linux?
  • Protect Your Connection and Privacy with Surfshark VPN
  • Can I Send Texts in iMessage with Effects from my Mac System?
  • How Do I Convert a Webp Graphics into a PNG in Windows?

On Our YouTube Channel

Monoprice DT-3BT Bluetooth Desktop Speakers -- REVIEW

FATORK Wi-Fi Smart Portable Movie Projector -- DEMO & REVIEW

Categories

  • AdSense, AdWords, and PPC Help (106)
  • Amazon, eBay, and Online Shopping Help, (161)
  • Android Help (202)
  • Apple iPad Help (145)
  • Apple Watch Help (53)
  • Articles, Tutorials, and Reviews (344)
  • Auto Tech Help (12)
  • Business Advice (199)
  • Chrome OS Help (25)
  • Computer & Internet Basics (764)
  • d) None of the Above (165)
  • Facebook Help (383)
  • Google, Chrome & Gmail Help (180)
  • HTML & Web Page Design (245)
  • Instagram Help (48)
  • iPhone & iOS Help (607)
  • iPod & MP3 Player Help (173)
  • Kindle & Nook Help (93)
  • LinkedIn Help (85)
  • Linux Help (167)
  • Linux Shell Script Programming (87)
  • Mac & MacOS Help (895)
  • Most Popular (16)
  • Outlook & Office 365 Help (26)
  • PayPal Help (69)
  • Pinterest Help (53)
  • Reddit Help (18)
  • SEO & Marketing (81)
  • Spam, Scams & Security (93)
  • Trade Show News & Updates (23)
  • Twitter Help (217)
  • Video Game Tips (66)
  • Web Site Traffic Tips (62)
  • Windows PC Help (922)
  • Wordpress Help (204)
  • Writing and Publishing (72)
  • YouTube Help (46)
  • YouTube Video Reviews (159)
  • Zoom, Skype & Video Chat Help (57)

Archives

Social Connections:

Ask Dave Taylor


Follow Me on Pinterest
Follow me on Twitter
Follow me on LinkedIn
Follow me on Instagram


AskDaveTaylor on Facebook



microsoft insider mvp


This web site is for the purpose of disseminating information for educational purposes, free of charge, for the benefit of all visitors. We take great care to provide quality information. However, we do not guarantee, and accept no legal liability whatsoever arising from or connected to, the accuracy, reliability, currency or completeness of any material contained on this site or on any linked site. Further, please note that by submitting a question or comment you're agreeing to our terms of service, which are: you relinquish any subsequent rights of ownership to your material by submitting it on this site. Our lawyer says "Thanks for your cooperation."
© 2022 by Dave Taylor. "Ask Dave Taylor®" is a registered trademark of Intuitive Systems, LLC.
Privacy Policy - Terms and Conditions - Accessibility Policy