Mac Automation: create a Mail-triggered "spy cam"
Have you ever been away from your Mac, then come back only to find that your co-worker has stolen your favorite Apple pen? Well, I am going to show you how to catch them in the act by creating a Mac "spy cam." For this how-to, you will need to create an Automator workflow, AppleScript, and some Mail rules. So, cue the James Bond music, and let's begin.
You do need an iSight or a newer Mac with a built-in camera. (Yes, I know there are some tools prebuilt to do this -- but what's the fun in that?)Continue reading to learn how to create the Mac spy cam.
Creating the Automator workflow
Let's first create the Automator workflow; this will take the picture and e-mail it to you. To create this workflow, just place the following Automator actions together (in the same order):
- Take Video Snapshot
- New Mail Message
- Send Outgoing Messages

Let's save the Automator workflow somewhere where you can find it later (for instance, you may want to create an "Automator" directory in your Documents directory). In Automator, click File > Save, select "Application" from the "Format" drop down box; type a file name, then click save.
Creating the AppleScript
This is going to be an extremely simple AppleScript, since Mail.app will open via the Automator action and that's about all we need. Open the Script Editor.app (found in ~/Applications/AppleScript/ ). Paste the following script into the editor (if you saved your Automator workflow as a different name, replace the "Take Pictures and E-mail" to the name of your saved workflow).
tell application "Take Picture and E-mail" to launch

Creating the mail rules
To link all the parts together, let's create the Mail rules. Open Mail.app's preferences (command + , ) then click Rules. Click the "Add Rule" button. Type a description and select "All" for the "If ALL of the following conditions are met."
Now let's add the conditions (you will have to click the plus sign to add more conditions):
- From ... Contains ... you@youremail.com
- Subject ... Is Equal To ... System&*Pic
- Message Content ... Contains ... Picture
- Set Color ... of Background ... Blue
- Run AppleScript ...
Running the Script
To run the script, all you need to do is send an e-mail from the account specified with "System&*Pic" in the subject line, and "Picture" in the body of your message.
Additional Information
- Please note that scripts such as these may be used against you by: co-workers, roommates, friends, crazy monkeys, and people on Digg
- By changing the subject line condition to be a "password," you will decrease the likeliness that #1 will happen
- You can include unusual characters for message content conditions (i.e. #, @, or ^) in order to avoid accidentally running a script that you didn't want (for example use: #shutdown# instead of just shutdown)
- It is also a good idea to have Mail.app check for new messages often for this to work well
Share
Source: http://tuaw.com/tag/automation
Have you ever been away from your Mac, then come back only to find that your co-worker has stolen your favorite Apple pen? Well, I am going...
Add a Comment
When I do this workflow, it does not send a picture, it send a place holder but not image
May 02 2008 at 1:48 AM Report abuse Permalink rate up rate down ReplyOr.... you could buy a copy of SecuritySpy (securityspy.com) and watch live video on your iPhone, capture video and snapshots triggered by customizable motion detection, automatically upload same to an ftp site and automatically email your boss video of your co-worker swiping your pen.
April 23 2008 at 12:54 AM Report abuse Permalink rate up rate down ReplyA lot easier and silent (no app opening just the green LED)
isightcapture for Leopard: http://scriptbuilders.net/files/isightcapture1.1.html
Create the folder "Terminal" in your home directory. Put isightcapture in it.
Create an apple script with this text and don't forget to replace "MY@MAIL.COM by your own eMail adress.
do shell script "~/Terminal/isightcapture ~/Terminal/snappit.jpg ; uuencode ~/Terminal/snappit.jpg snappit.jpg | mail -s CamPic MY@EMAIL.COM ; mv ~/Terminal/snappit.jpg ~/Terminal/`date +%y%m%d%H%M%S`.jpg"
(gMail webmail as problem reading the image but Mail.app do it just fine)
can you explain this script a little further?
I'm not sure it's working, and also when i try to take more than one snapshot it throws errors about doubling something (the filename should be different with the seconds included though?)
email me at adam@adamkramer.com if you'd prefer
Thanks!
any one no of a program like evo cam but that is is free?
April 22 2008 at 12:31 PM Report abuse Permalink rate up rate down ReplyI highly doubt you'll find anything free if you want any decent options that is. EvoCam is well worth it, they do their best to support cameras of all kinds.
2¢
Faslane
Wait wait, people use Macs at work?
April 22 2008 at 12:30 PM Report abuse Permalink rate up rate down ReplyHehe . . . yes we do, actually I'm thinking about setting this up for my wife (a teacher) to catch custodians stealing stuff from her classroom at night.
April 22 2008 at 1:16 PM Report abuse Permalink rate up rate down ReplyHate to be a nitpicker but Script Editor is not found in ~/Apps. That would be /Users/xxxxx/Apps. It's in /Applications.
April 22 2008 at 12:28 PM Report abuse Permalink rate up rate down ReplyI use a program called EvoCam it has lots of options dealing with the isight camera, I have it set to detect motion then it can upload it to a FTP site or email to you.
April 22 2008 at 11:39 AM Report abuse Permalink rate up rate down Replyhey, is there software / script to take a snapshot photo every 5 mins and say FTP or email ?
that would be handy.
Or - just install Skype, create 2 accounts and have it auto answer when the other account calls - and enable 'start video' on calls from contacts in my address book.
Full Motion HD Video (on a new Mac) with 2way voice..
This is neat (and I'm a huge believer in making your own tools, even if you're reinventing the wheel--it's a great way to learn) but what I really want is a way to remotely trigger a screenshot. The built-in 'screencapture' command-line utility no longer works unless you run it from a locally-spawned Terminal session. I used to have it in 'crontab' to run every minute on my own machine as a security measure, and I have a web-based front-end for it running on some computers in some conference rooms I manage. (Reply if you want the script.) Worked fine in 10.3 and 10.4; doesn't in 10.5--not even when run as root. I can create an Automator action that takes a screenshot but when you run that the icon appears in the Dock and I'd rather have this run totally invisibly.
April 22 2008 at 10:33 AM Report abuse Permalink rate up rate down Replybrian - is it different from the shellscript that i listed in my last comment?
April 22 2008 at 10:38 AM Report abuse Permalink rate up rate down Reply(Oops, replied to the wrong one.) We're two different things. I'm talking about taking a picture of the screen itself (a screenshot, like when you press shift-command-3), not taking a picture of the user with the camera.
April 22 2008 at 5:03 PM Report abuse Permalink rate up rate down ReplyHot Apps on TUAW
Deals of the Day
more deals- Refurb Apple MacBook Air Laptops: 12" 64GB SSD for $699 + free shipping
- JVC Motion Sensing Clock Radio with Dual iPod Docks for $55 + free shipping
- Apple iPhone Headset with Mic for $4 + $2 s&h
- miFrame Picture Frame Dock for iPad for $64 + $8 s&h
- Refurb Apple iPod nano 8GB MP3 Player for $99 + free shipping, 16GB for $119
- Hannspree Apple-Shaped 28" 1080p LCD HDTV for $270 + free shipping
Software Updates
more updates- EFI Firmware Update brings Lion Internet Recovery to 2010-model Macs
- OS X Lion 10.7.3 released with Safari 5.1.3, Wi-Fi bug fix
- Aperture updated to 3.2.2, addresses Photo Stream issue
- Apple updates Keynote to address Lion issues
- Google Search app gets new look on iPad
- Apple releases Apple TV Software Update 4.4.3



19 Comments