Re: iCal scripting problem
Re: iCal scripting problem
- Subject: Re: iCal scripting problem
- From: Paul Robinson <email@hidden>
- Date: Sun, 3 Oct 2004 13:00:44 +0100
On 2 Oct 2004, at 23:31, Christian Boyce wrote:
This indeed solves the problem but holy cow, how would anyone know
about the existence of "iCal Helper" and/or this business about who is
really running the script? I guess this is one of those "that's the
way it is, accept it and move on" but it sure would be nice if Apple
would make scripting its own programs a little bit easier to figure
out.
Yes, Apple could make things a little clearer here, but in their
defence, it probably never occurred to them that people wanted to
script iCal from iCal (so to speak) so they didn't realise the double
running behaviour would occur.
Might there be a way to set a property after the script has run once,
and then to check the value of the property, etc.? I was heading in
that direction but didn't get it to work. I'm not very experienced
with properties so I'm not so sure that the problem wasn't me.
Although this was my first thought, doing this by using properties
would have had to involve determining which application was running the
script. You could have a property that changed its state for the 1st
copy of the script (there is another problem here with actually getting
the script to save the change before the 2nd copy starts) which
dictated how much of the code the 2nd copy ran but what happens when
iCal is actually running? Only one copy of the script would run leaving
the property in the wrong state. This would stop a subsequent call of
the script by iCal from working. To make it work you need to know which
application is calling the script - which makes the need for a property
redundant.
Much obliged. You solved my problem, Paul.
(What I'm really doing with my script is sending emails to a group of
people reminding them of events in the calendar, not just putting up
dialog boxes that say "yo.")
... and you need to get into iCal to work out which event called the
script and (possibly) the people who should be emailed.
Since presumably you will identify the event by searching for an event
that has the current date as the start date +/- the offset for the
alarm, it's worth pointing out there is a problem with spotting events
that are reoccurring by this method - as well as being very slow for a
large number of events. The start date for reoccurring events is the
start date of the first ever occurrence, not the next future event.
Makes it hard to spot these when searching by start dates.
Here is a suggestion. It may not be appropriate for what you are trying
to do. When you select email as the action of the alarm, you are given
the option of sending email to yourself only. Makes it useless for
sending mail to others.
Not quite. What actually happens for "email me" alarms, is that iCal
sends a message to your email client via Applescript, when the alarm is
triggered. The Applescript is kept at
'/Applications/iCal.app/Contents/Resources/Mail.scpt' and in that
script, it is the 'on send_mail_sbr' handler that is called. Note that
the event title is actually passed by iCal to the handler. There is
nothing to prevent you adding your own code to the handler, calling
back to iCal, looking for the event with the same title. Assuming that
event titles are unique, this will allow you to identify which event
has been triggered more quickly, even if it is reoccurring.
To maintain the original function of the menu option, and allow you to
send mail to anybody, just add a dummy email address to your "me" card
in Address Book. This email address could be say "email@hidden."
When you next run iCal, you can select this as an option in the alarm
menu. Then put code in the handler that scans the "myrecipient"
variable, and if it's equal to the dummy email, gets all the relevant
email addresses from the event in iCal, and alters "myrecipient" to a
list of all recipients before using the existing code to send email.
HTH
P.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden