SecuritySpy 
Multi-camera video surveillance software for the Mac
AppleScript Examples
AppleScript is the a scripting language that is widely supported by Mac applications and used to automate tasks. SecuritySpy understands many commands to capture images, arm and disarm camera modes, and set various settings. You write scripts using the "AppleScript Editor" application in the /Applications/Utilities/ folder.
AppleScripts can be run from within the AppleScript Editor application, or alternatively saved as applications themselves, so they can be opened directly from the Finder and run independently. To do this, open a script in AppleScript Editor, choose Save As... from the File menu, choose Application as the File Format, make sure the Startup Screen option is disabled, and save the new script application:

To view the AppleScript commands supported by SecuritySpy, open AppleScript Editor, select Open Dictionary from the File menu, and select SecuritySpy. You can also view the SecuritySpy AppleScript commands here.
Camera Numbers
For commands that apply to specific cameras, you can either specify a camera name or a camera number. Camera numbers can be found via the Camera Info window in SecuritySpy, as highlighted in the screenshot below:

If you don't see this column in your Camera Info window, click on the header bar (where the column names are shown) for a menu that allows you to add columns.
For commands where it is appropriate, you can specify the camera number as -1 to mean "all cameras".
Regular Image Capture
This script demonstrates a regular image capture. The script tells SecuritySpy to capture one frame every 10 seconds from camera number 0, and saves it to disk into a "Captures" folder created on the Desktop, with a set file name depending on the current date and time.

Download the “Regular Image Capture” AppleScript file.
Triggering Motion-Detected Recording
This script simulates motion on camera 0. This could be useful to trigger a recording based on an external sensor such as a switch, infra-red sensor or doorbell.

Download the “Trigger Motion Detection” AppleScript file.
Enabling and disabling a camera, and setting camera settings
This script enables camera 0, and then disables it. This uses the camera settings HTTP POST request in SecuritySpy, so SecuritySpy's web server must be enabled. Make sure to modify the formURL property with the correct username, password, address and port of your SecuritySpy web server.
Full details of how to set all settings can be found via the Web Server Specification page.

Download the “Enabling and disabling” AppleScript file.
Send iMessage
This script captures an image file from a camera and sends it as an iMessage via the Messages app. You'll need to edit the script to set the correct camera number and recipient's phone number or email address (which must be in your address book). This script can be set in SecuritySpy as an Action to be performed upon motion detection.

Download the “Send iMessage” AppleScript file.
FaceTime Call
This script initiates a FaceTime call.

Download the “FaceTime Call” AppleScript file.
Pan/Tilt/Zoom Auto-Patrol
Note: as of version 5.2.3, this functionality is now built into SecuritySpy.
This script periodically tells camera 0 to move to PTZ preset 1, then preset 2, then preset 3. You should modify this script to add the presets you want to patrol, and also you can change the delay period (which is currently 10 seconds).

Download the “Pan/Tilt/Zoom Auto-Patrol” AppleScript file.
Button Click Image Capture
This script will present a small window with two buttons: "Stop" and "Capture". Click the Capture button repeatedly to capture still images from a particuliar camera; each image will be saved to disk and numbered sequentially, with an additional session number so that you don't have to empty the destination folder before starting a new capture session. Before running this script, in the "capture image" command, set the correct camera number, and set the path to a valid directory within your Documents folder.

Download the “Button Click Image Capture” AppleScript file.
Parse System Info
There is a "System Information" request available via SecuritySpy's web interface, which contains a wealth of information about each camera such as the resolution, mode and connection status. As a demonstration, this script gets and parses this information, and displays a message when a camera is offline. Instead of a message, you might find it useful to send an email to notify you of an offline camera, or link it up to a home automation system that automatically power-cycles the offending camera in an attempt to bring it back online.
For this script to work correctly, you will need to enable SecuritySpy's web server, and modify the "username:password" string in the script with the login to an Administrator web account.
Download the “Parse System Info” AppleScript file.
ProcessCapturedFile
When installed, this script will be automatically invoked by SecuritySpy for every captured file that is produced. You can use it to apply some additional processing to captured files, such as to move them to a particular folder, send them to another application or upload them to a server. In order for SecuritySpy invoke this script, it must be placed into the SecuritySpy folder within your Home folder (i.e. at ~/SecuritySpy/). The camera number, camera name and file path are passed into the script as parameters - the example script here demonstrates how the parameters work by simply displaying them in a dialog.

Download the “ProcessCapturedFile” AppleScript file.
Scheduling Scripts
Lingon is a great utility that can automatically run scripts on a schedule.