The dish on parenting ... check out the new ParentDish!

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

Now we need to change some of the settings for the actions. In the "Take Video Snapshot" workflow, make sure that the "Take picture automatically" checkbox is checked. Be sure to fill in the "New Mail Message" info for the To and Subject fields; also specify which account it will be sent from.

Saving the Automator workflow
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



Now save the AppleScript by clicking File > Save in the Script Editor. Type in a file name and make sure the "File Format" is set to "Script" before clicking the save button.

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):
  1. From ... Contains ... you@youremail.com
  2. Subject ... Is Equal To ... System&*Pic
  3. Message Content ... Contains ... Picture
Add these rules under "perform the following actions" :
  1. Set Color ... of Background ... Blue
  2. Run AppleScript ...
For the run AppleScript rule, click the choose button and find your AppleScript that you just made. Then click the "Choose File" button.

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
  1. Please note that scripts such as these may be used against you by: co-workers, roommates, friends, crazy monkeys, and people on Digg
  2. By changing the subject line condition to be a "password," you will decrease the likeliness that #1 will happen
  3. 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)
  4. It is also a good idea to have Mail.app check for new messages often for this to work well

Related Headlines

Reader Comments (Page 1 of 1)

Add your comments

Please keep your comments relevant to this blog entry. Email addresses are never displayed, but they are required to confirm your comments.

When you enter your name and email address, you'll be sent a link to confirm your comment, and a password. To leave another comment, just use that password.

To create a live link, simply type the URL (including http://) or email address and we will make it a live link for you. You can put up to 3 URLs in your comments. Line breaks and paragraphs are automatically converted — no need to use <p> or <br> tags.

New Users

Current Users

TUAW Features

Mac 101 iPhone Around the Worldask-tuaw
Mac News
Macworld (497)
.Mac (38)
Accessories (624)
Airport (75)
Analysis / Opinion (1292)
Apple (1609)
Apple Corporate (547)
Apple Financial (186)
Apple History (38)
Apple Professional (49)
Apple TV (160)
Audio (441)
Bad Apple (119)
Beta Beat (148)
Blogging (87)
Bluetooth (15)
Bugs/Recalls (56)
Cult of Mac (869)
Deals (200)
Desktops (114)
Developer (205)
Education (93)
eMac (10)
Enterprise (126)
Features (373)
Freeware (363)
Gaming (344)
Graphic Design (18)
Hardware (1270)
Holidays (41)
Humor (587)
iBook (65)
iLife (237)
iMac (183)
Internet (306)
Internet Tools (1289)
iPhone (1350)
iPod Family (2020)
iTS (962)
iTunes (794)
iWork (18)
Leopard (355)
Mac mini (109)
Mac Pro (50)
MacBook (197)
MacBook Air (77)
Macbook Pro (215)
Multimedia (433)
Odds and ends (1417)
Open Source (271)
OS (890)
Peripherals (190)
Podcasting (181)
Podcasts (83)
Portables (197)
PowerBook (138)
PowerMac G5 (50)
Retail (572)
Retro Mac (47)
Rig of the Week (42)
Rumors (612)
Software (4220)
Software Update (395)
Steve Jobs (252)
Stocking Stuffers (55)
Surveys and Polls (97)
Switchers (111)
The Woz (34)
TUAW Business (227)
Universal Binary (281)
UNIX / BSD (62)
Video (909)
Weekend Review (74)
WIN Business (49)
Wireless (80)
XServe (35)
Mac Events
One More Thing (27)
Liveblog (0)
Other Events (231)
WWDC (181)
Mac Learning
Ask TUAW (96)
Blogs (85)
Books (23)
Books and Blogs (63)
Cool tools (444)
Hacks (462)
How-tos (480)
Interviews (33)
Mods (184)
Productivity (583)
Reviews (99)
Security (145)
Terminal Tips (56)
Tips and tricks (559)
Troubleshooting (161)
TUAW Features
iPhone 101 (23)
TUAW Labs (3)
Blast From the Past (17)
TUAW Tips (141)
Flickr Find (32)
Found Footage (70)
Mac 101 (81)
TUAW Interview (30)
Widget Watch (196)
The Daily Best (2)
TUAW Faceoff (5)

RESOURCES

RSS NEWSFEEDS

Powered by Blogsmith

Sponsored Links

The Unofficial Apple Weblog (TUAW) bloggers (30 days)

#BloggerPostsCmts
1Dave Caolo490
2Cory Bohon455
3Mat Lu374
4Erica Sadun351
5Scott McNulty341
6Michael Rose2919
7Brett Terpstra240
8Mike Schramm194
9Robert Palmer1323
10Steven Sande139
11Christina Warren618
12Joshua Ellis64
13Nik Fletcher41
14Chris Ullrich21
15Jason Clarke11
16Lisa Hoover11
17Victor Agreda, Jr.14

Featured Galleries

Macworld 2008 Keynote
Macworld 2008 Build-up
Macworld Expo 2007 show floor
The Macworld Faithful in Line
iPhone First Look
iPhone 2.0 - .Mac push e-mail
iMac 1998
TUAW Faceoff: Screenshot apps on the firing line
Boston Apple Store (Boylston Street)

 

    Most Commented On (7 days)

    Recent Comments

    More Apple Analysis

    More from AOL Money and Finance

    Weblogs, Inc. Network

    Other Weblogs Inc. Network blogs you might be interested in: