Created
March 18, 2013 01:34
-
-
Save benwaldie/5184446 to your computer and use it in GitHub Desktop.
TUAW > Triggering AppleScripts from Calendar Alerts in Mountain Lion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- This property controls the calendar on which the event is added | |
set theCalendarName to "AppleScripts" | |
-- Prompt the user to select a script to attach to an event. This should be an application. | |
set theScriptToTrigger to choose file with prompt "Please select a saved AppleScript application to attach to an event:" of type "app" | |
-- Get the script's name | |
set theScriptToTriggerName to displayed name of (info for theScriptToTrigger) | |
-- Check for the existence of the target calendar, creating it if it doesn't already exist | |
tell application "Calendar" | |
if (calendar theCalendarName exists) = false then | |
make new calendar with properties {name:theCalendarName} | |
end if | |
-- Get the current date and time | |
set theCurrentDate to current date | |
-- Create a new event at the current date and time | |
set theEvent to make new event at end of calendar theCalendarName with properties {summary:"AppleScript Trigger: " & theScriptToTriggerName, start date:theCurrentDate, end date:theCurrentDate} | |
-- Add an open file alarm to the newly created event and set it to open the selected script app | |
make new open file alarm at theEvent with properties {trigger interval:0, filepath:POSIX path of theScriptToTrigger} | |
end tell |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The open file alarm creation seems to stopped working in the latests versions of Mac OS X (I have Yosemite). I've been trying to execute this script and other similar scripts correctly for more than 2 hours, but every time, the events gets created, but without the alarm.
Anybody knows if there's a way to fix this?