1 Reply Latest reply: May 12, 2011 1:14 AM by John Maisey
Dan Erlandson Level 1 Level 1 (55 points)

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)
  • 1. Re: applescript in iCal
    John Maisey Level 5 Level 5 (6,880 points)

    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