Hello there -
Does anyone know how to query iCal for the “current” event – e.g. the event selected and/or displayed in the info window?
Thanks a lot -
jb
Hello there -
Does anyone know how to query iCal for the “current” event – e.g. the event selected and/or displayed in the info window?
Thanks a lot -
jb
If you’re running a script as an alarm it’s the “last event.”
I use the following in an alarm script:
tell application “iCal”
launch
set cal_ref to item 1 of (every calendar whose title is “Personal”)
set event_alarm to (last event of cal_ref)
set start_date to (start date of event_alarm)
quit
end tell
The idea here would be that the script would be triggered from outside of iCal. That is, I’ve made a set of scripts that associate specific Eudora emails with iCal events and todos. I want to be able to ask iCal to cough up the ID of the email I’ve associated with the frontmost event (the one I’m looking at), so that I can perform some actions on the email in Eudora.
Thanks for the suggestion, though.
So, does anyone know how I’d get “the event under my nose”?
jb
I don’t see anything in the iCal dictionary that would allow you to do this.
– Rob
I don’t think there is anything in the ical dictionary either, but a possible workaround is just to cut and immediately paste the event, which automatically puts it at the bottom of the event list.
Here is a rough-and-ready script that does this, and then adds an alarm to the event:
tell application “System Events”
tell process “ical”
set frontmost to true
tell menu “Edit” of menu bar item “Edit” of menu bar 1
get UI elements
click menu item “Cut”
click menu item “Paste”
end tell
end tell
end tell
tell application “iCal”
tell calendar 1
set eventnumber to count each event
make new display alarm at the end of display alarms of event eventnumber with properties {trigger interval:-15}
end tell
end tell
Hi,
I thought I posted this already but there’s an easier way using System Events beta. If an event is selected and not being editted, then you can just keystroke return. This highlights the Event Summary. Then, you Copy and get the clipboard text. This gives you the Summary of the selected event.
Note that if the selected event is being editted, then retturn just moves to the next text field and copy will copy the text from that field. So, a lot of error checking needs to be done.
gl,
Speaking of iCal scripting, can anyone tell me how I might get the text of all calendar events of the current date into the clipboard?
Your script works great. I now have a Open URL script which I can run as an alarm action:
tell application "iCal"
activate
set cal_ref to item 1 of (every calendar whose title is "Work")
set event_alarm to (last event of cal_ref)
set theUrl to (url of event_alarm)
close window 1
end tell
tell application "Safari"
open location theUrl
end tell