Re: Add event to Calendar
Re: Add event to Calendar
- Subject: Re: Add event to Calendar
- From: Paul Berkowitz <email@hidden>
- Date: Sun, 14 Sep 2014 17:07:17 -0700
- Thread-topic: Add event to Calendar
Title: Re: Add event to Calendar
I haven't tested, but remembering similar issues in earlier versions of Calendar (and iCal), I would suggest that after making the new event, you try a simple
save
(You may or may not also want to reload calendars after trhe save, but it's probaby not necessary.)
Also, not that it matters too much, instead of a separate line copying the result to vEventInfo, you could do it by:
tell (first calendar whose name is calendarName)
set vEventInfo to make new event at end of events with properties {summary:theSummary, start date:startDate, end date:endDate, description:theDescrption, location:theLocation}
end tell
You might also want to view the calendar (in case another calendar had been in view) before showing the event. Again, you should do that by setting a variable to it so you only have to get it once:
tell application "Calendar"
activate
set vCalendar to (first calendar whose name is calendarName)
tell vCalendar
set vEventInfo to make new event at end of events with properties {summary:theSummary, start date:startDate, end date:endDate, description:theDescrption, location:theLocation}
end tell
save
view calendar at startDate
show vEventInfo
end tell
Unfortunately the 'inspector' (window) is part of the object model not in the AppleScript dictionary, so there's no way to open it other than your GUI scripting. Although telling System Events directly seems to work now, the 'approved' method (I may be out of date) require(d) telling the Calendar process within it. It might still be safer:
tell application "System Events"
tell process "Calendar"
keystroke "i" using command down
end tell
end tell
--
Paul Berkowitz
From: Bill Vlahos <email@hidden>
Date: Sun, 14 Sep 2014 07:49:47 -0700
To: AppleScript-Users <email@hidden>
Subject: Re: Add event to Calendar
Christian,
Thanks for the feedback. BTW I’m on Mavericks 10.9.4
Oh that’s interesting. I had only tried it on my “Home” calendar where there is the reproducible delay I described. If I add it to any of the other calendars the event shows up instantly (I’m showing all of the calendars). Even when I am adding the event to the Home calendar the script pops up the Info window on it which is weird because you don’t yet see the event on the calendar.
I wonder why there is a delay for the Home calendar. Anyone have an idea?
Here is the complete AppleScript that will not only create the event but also bring up the Info pane to let the user add invitees, etc. I have to show the event so it is highlighted so the keystroke command has the event to work with.
set calendarName to "Work"
set theSummary to "Title of the event goes here"
set theDescrption to "Description of event goes here."
set theLocation to ""
set startDate to "September 15, 2014 9:30:00 AM"
set endDate to "September 15, 2014 1:00:00 PM"
set startDate to date startDate
set endDate to date endDate
tell application "Calendar" to activate
tell application "Calendar"
tell (first calendar whose name is calendarName)
make new event at end of events with properties {summary:theSummary, start date:startDate, end date:endDate, description:theDescrption, location:theLocation}
copy the result to vEventInfo
end tell
show vEventInfo
end tell
tell application "System Events"
keystroke "i" using command down
end tell
Bill Vlahos
On Sep 14, 2014, at 6:20 AM, Christian Boyce <email@hidden> wrote:
Over here your script makes an event in my "Home" calendar instantly, as long as I am showing the "Home" calendar.
10.8.5.
c
On Sep 14, 2014, at 12:19 AM, Bill Vlahos <email@hidden> wrote:
I’m trying to create a new calendar event in the Calendar application and then edit the event so it is opened and ready to address and send out.
The following AppleScript successfully creates an event but it isn’t visible on the calendar until either I manually select Refresh Calendars in the View menu or wait until the Calendar syncs up with the server.
set calendarName to "Home"
set theSummary to "Event Title"
set theDescrption to "The notes for the event"
set theLocation to "Karl's House"
set startDate to "September 15, 2014 9:30:00 AM"
set endDate to "September 15, 2014 1:00:00 PM"
set startDate to date startDate
set endDate to date endDate
tell application "Calendar"
tell (first calendar whose name is calendarName)
make new event at end of events with properties {summary:theSummary, start date:startDate, end date:endDate, description:theDescrption, location:theLocation}
end tell
end tell
Questions:
1. How can I trigger an immediate refresh? The AppleScript dictionary command reload calendars doesn’t do it.
2. How can I trigger an immediate opening of the event?
Thanks,
Bill Vlahos
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden
--
Christian Boyce
Christian Boyce and Associates
Mac, iPhone, and iPad Consultants
For appointments, please call the office: 424-354-3548.
We do not make appointments by email or text.
Read the Boyce Blog: http://christianboyce.blogspot.com <http://christianboyce.blogspot.com/>
Follow us on Twitter! http://twitter.com/christianboyce
Be a fan on Facebook! http://facebook.com/christianboyce.and.associates
Now Playing on The Boyce Blog: Thoughts on Apple's iPhone 6, 6 Plus, and the Apple Watch <http://christianboyce.blogspot.com/2014/09/thoughts-on-apple-iphone-6-6-plus-and.html>
(Join The Boyce Blog mailing list <https://confirmsubscription.com/h/d/15BCAA37978B70C5> and never miss a post!)
Current weather in Santa Monica, CA: Fair, 71° F
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden