Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

applescript in iCal

I have a script that i am looking to attach to different all day events in iCal during the year. The script is supposed to modify the start and end times of other events on that particular day. I can get the script to run correctly and do its thing when the actual current date is the date of the all day event where the script is imbedded. My question is: how can I configure that applescript to look for and get the date of the all day event where it (the applescript) is actually imbedded, so that when it runs it modifies the events on that date, not the "current date". Hope that is clear!


Thanks


dan

2 GHz Mac Book, Mac OS X (10.6.4)

Posted on May 11, 2011 6:31 PM

Reply
1 reply

May 12, 2011 1:14 AM in response to Dan Erlandson

Hi Dan,


To do this with Applescript is not as easy as it should be. Here is a script originally posted by Austin Kinsella1 a few years ago (see Re: iCal Alarm - Pass Event data to AppleScript? ). I cannot check if it works on the current iCal, but I believe it will. I would modify it to only look in the calendar I know the events will be in.


Best wishes

John M


(*

called from iCal as on alarm, will speak the title of the alarm event

won't work for repeating events

AK ITCarlow Nov 2004

*)

set Now to current date

-- Adjust FuzzSeconds to suit; if too big, close events will speak several times

set FuzzSeconds to 15

tell application "iCal"

set MyEvents to every event of every calendar where ((start date of it) ≥ (current date))

repeat with ThisEvent in MyEvents--scan the list looking for events that have triggered us

try

set MinutesBefore to (trigger interval of open file alarm of ThisEvent) as number

set TriggerInt to (Now - ((start date of ThisEvent) + 60 * MinutesBefore)) --notionally 0 for firing event

if (TriggerInt < FuzzSeconds) and (TriggerInt > (-FuzzSeconds)) then

say (summary of ThisEvent as text) & " at " & (start date of ThisEvent as text)


-- ThisEvent should a reference to the event,


-- so you should be able to get the start date from it.


-- You may want to do some checking first.

end if

end try

end repeat

end tell

applescript in iCal

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.