Applescript & iCal announce multiple events

Sorry. My fault. I’ll get onto it.

Later: OK. Done. I’d forgotten I’d have to use the Calendars’ names instead of their indices getting the data the way I did. It now works named calendar by named calendar and you can preset the names at the top of the script.

It really needs a modification to sort the announcements by event time… :rolleyes: I’ll think about it after supper.

OK. It now has that too. It should speak the announcements in appointment order regardless of the order in which they were obtained.

That is amazing. I can’t even begin to imagine how to figure that all out. The only thing I noticed is if you have something scheduled during Noon/12PM it say “12 AM”? Other than that the script is perfect!!! Thanks NG

A hangover from the original script. Not me this time. :slight_smile: Now fixed.

Thanks Nigel for all your help, I got it working brilliantly!
Here are some little tweaks I made and would like to share. I added some randomizing txt so it doesn’t get so repetitive.

::Greeting::


-- User Name
set userName to long user name of (system info)

-- Randomizer Greeting
property oldrandnum : missing value
set greetings to {"It's time to wake up!", "Rise and Shine!", "Snoozle doozle!", "Sleepy Head!", "Carpe Diem, seize the day!", "Tiger!"}
set countgreetings to length of greetings
repeat
	set randnum to random number from 1 to countgreetings
	if oldrandnum is missing value or (randnum ≠ oldrandnum) or (countgreetings = 1) then
		set oldrandnum to randnum
		exit repeat
	end if
end repeat
set greeting to item randnum of greetings

-- Time of Day
set the_hours to hours of (current date)
if the_hours is less than 8 then
	say "Good Morning," & greeting
else if the_hours is less than 12 then
	say "Good Morning" & userName
else if the_hours is less than 17 then
	say "Good Afternoon" & userName
else
	say "Good Evening" & userName
end if

-- Randomize Day
set currentday to (do shell script "date +%A")
-- Monday
if currentday is "Monday" then
	set FirstDays to {"Happy Monday!", "It is Monday", "Today is Monday", "Sorry to be the bearer of bad news, but, it is Monday again"}
	set FirstDay to some item of FirstDays
	set currentday to SecondDay
	
	-- Tuesday	
else if currentday is "Tuesday" then
	set SecondDays to {"Happy Tuesday!", "It's Taco Tuesday!", "Today is Tuesday"}
	set SecondDay to some item of SecondDays
	set currentday to SecondDay
	
	-- Wednesday		
else if currentday is "Wednesday" then
	set ThirdDays to {"Happy Wednesday!", "Happy Hump day. The humpty dance is your chance, to do the hump...", "It is Wednesday", "Happy Hump day"}
	set ThirdDay to some item of ThirdDays
	set currentday to ThirdDay
	
	-- Thursday
else if currentday is "Thursday" then
	set ForthDays to {"It is Thirsty Thursday!", "Happy Thurday!", "Happy Friday-Eve", "Today is Thursday"}
	set ForthDay to some item of ForthDays
	set currentday to ForthDay
	
	-- Friday	
else if currentday is "Friday" then
	set FifthDays to {"Happy Friday!", " You are all most there, tomorrow's the weekend", "One day to go, tomorrow is Saturday", "It is Friday", "It is Friday"}
	set FifthDay to some item of FifthDays
	set currentday to FifthDay
	
	-- Saturday	
else if currentday is "Saturday" then
	set SixthDays to {"Happy Saturday", "Huzzuh today is Saturday", "It is Saturday", "I hope you have Great Saturday"}
	set SixthDay to some item of SixthDays
	set currentday to SixthDay
	
	-- Sunday	
else if currentday is "Sunday" then
	set SeventhDays to {"Happy Sunday", "Welcome to Sunday Funday", "Today is Sunday bloody Sunday", "I hope you are enjoying your Sunday", "It is Sunday"}
	set SeventhDay to some item of SeventhDays
	set currentday to SeventhDay
	
	
end if

delay 0.3
say currentday

delay 0.3
say "the time right now is " & getTimeInHoursAndMinutes()


on getTimeInHoursAndMinutes()
	
	-- Get the "hour"
	set timeStr to time string of (current date)
	set Pos to offset of ":" in timeStr
	set theHour to characters 1 thru (Pos - 1) of timeStr as string
	set timeStr to characters (Pos + 1) through end of timeStr as string
	
	-- Get the "minute"
	set Pos to offset of ":" in timeStr
	set theMin to characters 1 thru (Pos - 1) of timeStr as string
	set timeStr to characters (Pos + 1) through end of timeStr as string
	
	--Get "AM or PM"
	set Pos to offset of " " in timeStr
	set theSfx to characters (Pos + 1) through end of timeStr as string
	
	return (theHour & ":" & theMin & " " & theSfx) as string
	
end getTimeInHoursAndMinutes

-OR-
::More simple greeting version::


-- Randomizer Greeting
property oldrandnum : missing value
set greetings to {"It's time to wake up!", "Rise and Shine!", "Snoozle doozle!", "Sleepy Head!", "Carpe Diem, seize the day!", "Tiger!"}
set countgreetings to length of greetings
repeat
	set randnum to random number from 1 to countgreetings
	if oldrandnum is missing value or (randnum ≠ oldrandnum) or (countgreetings = 1) then
		set oldrandnum to randnum
		exit repeat
	end if
end repeat
set greeting to item randnum of greetings

#set userName to long user name of (system info)

-- Time of Day Greeting
set the_hours to hours of (current date)
if the_hours is less than 8 then
	say "Good Morning," & greeting
else if the_hours is less than 13 then
	say "Good Morning"
else if the_hours is less than 18 then
	say "Good Afternoon"
else
	say "Good Evening"
end if
delay 0.5
say "it is " & getTimeInHoursAndMinutes()

on getTimeInHoursAndMinutes()
	
	-- Get the "hour"
	set timeStr to time string of (current date)
	set Pos to offset of ":" in timeStr
	set theHour to characters 1 thru (Pos - 1) of timeStr as string
	set timeStr to characters (Pos + 1) through end of timeStr as string
	
	-- Get the "minute"
	set Pos to offset of ":" in timeStr
	set theMin to characters 1 thru (Pos - 1) of timeStr as string
	set timeStr to characters (Pos + 1) through end of timeStr as string
	
	--Get "AM or PM"
	set Pos to offset of " " in timeStr
	set theSfx to characters (Pos + 1) through end of timeStr as string
	
	return (theHour & ":" & theMin & " " & theSfx) as string
	
end getTimeInHoursAndMinutes

::Local Weather:: You’ll need to replace the CityCode with your local one & towards the bottom of the script the name of the City.


--this is the city code. Search the code for your city on http://weather.yahoo.com/
set CityCode to 2430683
--temperature format
set t_format to "F"
--voiceover format
set v_format to "S"
--say present condition
set a_format to "Y"

set IURL to "http://weather.yahooapis.com/forecastrss?w=" & CityCode

--downloading the file using curl
set file_content to (do shell script "curl " & IURL)
--looking for the line with actual condition
set theText to text ((offset of "yweather:condition" in file_content) + 1) thru -1 of file_content
set sub_1 to text ((offset of "\"" in theText) + 1) thru -1 of theText

--today conditions found
set actual_condition to text 1 thru ((offset of "\"" in sub_1) - 1) of sub_1

--looking for actual temperature temperature
set sub_1a to text ((offset of "temp=" in sub_1)) thru -1 of sub_1
set sub_1b to text ((offset of "\"" in sub_1a) + 1) thru -1 of sub_1a
set actual_temp to text 1 thru ((offset of "\"" in sub_1b) - 1) of sub_1b

if t_format is equal to "C" then
	set actual_temp to (5 / 9) * (actual_temp - 32) as integer
end if

--looking for today forecast
set theText to text ((offset of "yweather:forecast" in file_content) + 1) thru -1 of file_content
set sub_2 to text ((offset of "\"" in theText) + 1) thru -1 of theText

--maximum and minimum temperatures found
set today_min_temp to word 9 of sub_2
set today_max_temp to word 12 of sub_2
if t_format is equal to "C" then
	set today_min_temp to (5 / 9) * (today_min_temp - 32) as integer
	set today_max_temp to (5 / 9) * (today_max_temp - 32) as integer
end if

--looking for today forecast condition (a bit tricky)
set sub_3 to text ((offset of "text" in sub_2) + 1) thru -1 of sub_2
set sub_4 to text ((offset of "\"" in sub_3) + 1) thru -1 of sub_3
set today_forecast to text 1 thru ((offset of "\"" in sub_4) - 1) of sub_4

--looking for tomorrow forecast
set sub_5 to text ((offset of "yweather:forecast" in sub_4) + 1) thru -1 of sub_4
set sub_6 to text ((offset of "\"" in sub_5) + 1) thru -1 of sub_5

--maximum and minimum temperatures found
set tomorrow_min_temp to word 9 of sub_6
set tomorrow_max_temp to word 12 of sub_6
if t_format is equal to "C" then
	set tomorrow_min_temp to (5 / 9) * (tomorrow_min_temp - 32) as integer
	set tomorrow_max_temp to (5 / 9) * (tomorrow_max_temp - 32) as integer
end if

set sub_7 to text ((offset of "text" in sub_6) + 1) thru -1 of sub_6
set sub_8 to text ((offset of "\"" in sub_7) + 1) thru -1 of sub_7
set tomorrow_forecast to text 1 thru ((offset of "\"" in sub_8) - 1) of sub_8

if v_format is equal to "L" then
	say "The current conditions in Kansas City are: " & today_forecast & ". Outside temperature will be: between " & today_min_temp & " and " & today_max_temp & " degrees. 
	Tomorrow: " & tomorrow_forecast & ", with a low of " & tomorrow_min_temp & ", and a high of " & tomorrow_max_temp & " degrees"
else
	say "The current weather in Kansas City is: " & today_forecast & ", between " & today_min_temp & ", and " & today_max_temp & " degrees. 
	 Tomorrow: " & tomorrow_forecast & ", with a low of " & tomorrow_min_temp & " ,and a high of " & tomorrow_max_temp & " degrees"
	
end if

::calendar:: Added some random txt to break up the “You have a Meeting” so it sound more natural.


set calendarNames to {"Home", "Work"}

set today to (current date)
set today's time to 0
set tomorrow to today + days
set myMeetings to {}

repeat with calName in calendarNames
	-- Get the start dates of all the events in this calendar.
	-- It could take some time if there are a lot of events.
	tell application "Calendar" to set thisCalendarsStartDates to start date of every event of calendar calName
	
	-- Examine the start dates and act on those which occur today.
	repeat with evnt from 1 to (count thisCalendarsStartDates)
		set theStartDate to item evnt of thisCalendarsStartDates
		if ((theStartDate is greater than or equal to today) and (theStartDate is less than tomorrow)) then
			-- If this start date occurs today, get further information from the event to which it belongs.
			tell application "Calendar" to set {summary:theSummary, end date:theEndDate, allday event:allDayEvent} to event evnt of calendar calName
			
			-- If the event's a 24-hour all-day event, or an ordinary event which ends today, prepare appropriate spoken text.
			set theTime to missing value
			if (allDayEvent) then
				if (theEndDate is theStartDate + days) then set theTime to "First, there is an All-day event"
			else if (theEndDate is less than or equal to tomorrow) then
				-- Get a representation of the start time in 12-hour time.
				set {hours:Eventhour, minutes:Eventminute} to theStartDate
				set pre to item (Eventhour div 12 + 1) of {"AM", "PM"}
				set Eventhour to (Eventhour + 11) mod 12 + 1
				if (Eventminute is 0) then set Eventminute to ""
				set theTime to "at " & Eventhour & " " & Eventminute & " " & pre
			end if
			-- Put both the start date and the meeting text into the meetings list as a pair.
			set conjunctions to {" you have scheduled,", " there is,", " you have a meeting,"}
			set conjunction to some item of conjunctions
			if (theTime is not missing value) then set the end of myMeetings to {theStartDate, theTime & conjunction & theSummary}
		end if
	end repeat
end repeat

-- Custom comparer for a customisable sort. It compares lists by their first items.
script sortOnItem1
	on isGreater(a, b)
		return (item 1 of a > item 1 of b)
	end isGreater
end script

-- Sort items 1 thru -1 of myMeetings using sortOnItem1 to compare them ” ie. sort on the start dates.
CustomInsertionSort(myMeetings, 1, -1, {comparer:sortOnItem1})

-- Speak the prepared texts (item 2 of each item of myMeetings) in order.
set greetings to {"Let's take a quick look at your calendar.", "Let's see what you have going on today.", "Let's see how busy your day looks.", "Here's whats on your calendar."}
set greeting to some item of greetings
say greeting
delay 0.5
set numberOfMeetings to (count myMeetings)
if (numberOfMeetings is 0) then
	set preamble to "You have nothing on your schedule for today,"
else if (numberOfMeetings is 1) then
	set preamble to "There is one event for today"
else
	set preamble to "You better get moving, there are " & numberOfMeetings & " upcoming appointments."
end if
say preamble
delay 1
repeat with thismeeting in myMeetings
	say item 2 of thismeeting
	delay 0.5
end repeat
say "That's everything for," & (date string of today)

on CustomInsertionSort(theList, l, r, customiser)
	script o
		property comparer : me
		property slave : me
		property lst : theList
		
		on isrt(l, r)
			set u to item l of o's lst
			repeat with j from (l + 1) to r
				set v to item j of o's lst
				if (comparer's isGreater(u, v)) then
					set here to l
					set item j of o's lst to u
					repeat with i from (j - 2) to l by -1
						tell item i of o's lst
							if (comparer's isGreater(it, v)) then
								set item (i + 1) of o's lst to it
							else
								set here to i + 1
								exit repeat
							end if
						end tell
					end repeat
					set item here of o's lst to v
					slave's shift(here, j)
				else
					set u to v
				end if
			end repeat
		end isrt
		
		-- Default comparison and slave handlers for an ordinary sort.
		on isGreater(a, b)
			(a > b)
		end isGreater
		
		on shift(a, b)
		end shift
	end script
	
	-- Process the input parameters.
	set listLen to (count theList)
	if (listLen > 1) then
		-- Negative and/or transposed range indices.
		if (l < 0) then set l to listLen + l + 1
		if (r < 0) then set r to listLen + r + 1
		if (l > r) then set {l, r} to {r, l}
		
		-- Supplied or default customisation scripts.
		if (customiser's class is record) then set {comparer:o's comparer, slave:o's slave} to (customiser & {comparer:o, slave:o})
		
		-- Do the sort.
		o's isrt(l, r)
	end if
	
	return -- nothing.
end CustomInsertionSort

ENJOY! Let me know if someone finds a way to speed up the calendar. The delay at the beginning isn’t horrible but I would love to see it get faster. Also if anyone know of a way to figure out a script to determine the time until your next event of the current day, that would be helpful. For instance “Good after noon, UserName, the time is 11:35 AM… You have 25 minutes until your next work event titled [Lunch Meeting]!” Thanks!

Hi,

just for fun, this is a shorter version of your greeting script.


property weekdayGreetings : {{"Happy Sunday", "Welcome to Sunday Funday", "Today is Sunday bloody Sunday", "I hope you are enjoying your Sunday", "It is Sunday"}, {"Happy Monday!", "It is Monday", "Today is Monday", "Sorry to be the bearer of bad news, but, it is Monday again"}, {"Happy Tuesday!", "It's Taco Tuesday!", "Today is Tuesday"}, {"Happy Wednesday!", "Happy Hump day. The humpty dance is your chance, to do the hump...", "It is Wednesday", "Happy Hump day"}, {"It is Thirsty Thursday!", "Happy Thurday!", "Happy Friday-Eve", "Today is Thursday"}, {"Happy Friday!", " You are all most there, tomorrow's the weekend", "One day to go, tomorrow is Saturday", "It is Friday", "It is Friday"}, {"Happy Saturday", "Huzzuh today is Saturday", "It is Saturday", "I hope you have Great Saturday"}} -- edited according to Nigel's note
property oldrandnum : missing value

--user name
set userName to long user name of (system info)

-- Time of Day
tell (current date) to set {the_hours, currentWeekday} to {its hours, its weekday as integer} -- edited according to Nigel's note
if the_hours is less than 8 then
	set greeting to randomizerGreeting()
	say "Good Morning," & greeting
else if the_hours is less than 12 then
	say "Good Morning" & userName
else if the_hours is less than 17 then
	say "Good Afternoon" & userName
else
	say "Good Evening" & userName
end if

set currentday to some item of item currentWeekday of weekdayGreetings

delay 0.3
say currentday

delay 0.3
say "the time right now is " & (do shell script "date +%l' '%M' '%p")

on randomizerGreeting()
	set greetings to {"It's time to wake up!", "Rise and Shine!", "Snoozle doozle!", "Sleepy Head!", "Carpe Diem, seize the day!", "Tiger!"}
	set countgreetings to length of greetings
	repeat
		set randnum to random number from 1 to countgreetings
		if oldrandnum is missing value or (randnum ≠ oldrandnum) or (countgreetings = 1) then
			set oldrandnum to randnum
			exit repeat
		end if
	end repeat
	return item randnum of greetings
end randomizerGreeting

Wow, Stefan thats awesome! Thanks that is much cleaner than what I come up with.

Nice script. Think I’d rather have the short user name.

kel1 try…
set userName to short user name of (system info)
Or
set userName to do shell script “whoami”

Also you can try this script I found…


tell application "System Events"
	set full_name to full name of current user as string
	set first_name to first word of full_name as string
end tell
say "Hello " & first_name & ", hey,   whats up?"

Hi.

That should be its hours, otherwise you get 3600.

And the Sunday greetings should be the first in the list at the top of the script. AppleScript weeks start on Sundays.

Of course, thanks.

I tested it on 22:30 local time, so it didn’t catch my eyes at once :wink:

Edit: I changed the script accordingly

Since I can’t figure out a way to get reoccurring dates on the calendar to get spoken in the Event script I figured out a work-around, by manually setting up personal dates “Holiday’s, Birthdays…” in a stand alone script. This gets spoken after the greeting script, before the current weather forecast.


-- Personal Event Reminder
set {year:y, month:m, day:d} to (current date)

set m to (month of (current date)) as integer
set d to (day of (current date))
set y to (year of (current date))

set MyEvents to {m, d}

if MyEvents = {1, 1} then
	say "Happy New Year! Welcome to," & (y)
	
else if MyEvents = {1, 16} then
	say "Today is Chris's Birthday."
	
else if MyEvents = {2, 2} then
	say "Happy Groundhog Day."
	
else if MyEvents = {2, 14} then
	say "Happy Valentine's Day!"
	
else if MyEvents = {3, 17} then
	say "Happy I hate my liver day, a.k.a. St. Patrick's Day!"
	
else if MyEvents = {4, 15} then
	say "Today is Tax day!"
	
else if MyEvents = {6, 4} then
	say "Happy 4th of July. Let's blow some shit up!"
	
else if MyEvents = {10, 31} then
	say "Trick or Treat, Happy All Hallows Eve!"
	
else if MyEvents = {12, 14} then
	say "Happy Birthday Sara!"
	
else if MyEvents = {12, 23} then
	say "2 Days till Chrismas! I hope you've finished all your shopping."
	
else if MyEvents = {12, 24} then
	say "It's Christmas Eve!"
	
else if MyEvents = {12, 25} then
	say "Merry Christmas!"
	
else if MyEvents = {12, 31} then
	say "Happy New Years Eve! Say goodbye to" & (y)
	
end if

Hi soxmonky.

Here’s a slight reworking of your script.

  1. It’s better to call ‘current date’ only once if only one date’s involved.
  2. The nested ‘if’ system I’ve used below reduces the number of tests done overall. For instance, today’s 5th January, for which there are no events. Rather than testing all the conditions {1, 1} thru {12, 31} before not saying anything, the nested system only tests for January and then for 1 and 16. After that, the action cuts to the end of the main ‘if’ block. Similarly, if today were 31st December, the nested system would only need to test the months to match December before testing the days thereof, rather than testing every single month/day condition for which there are greetings:

-- Personal Event Reminder
set {year:y, month:m, day:d} to (current date)

if (m is January) then
	if (d is 1) then
		say "Happy New Year! Welcome to," & (y)
	else if (d is 16) then
		say "Today is Chris's Birthday."
	end if
	
else if (m is February) then
	if (d is 2) then
		say "Happy Groundhog Day."
	else if (d is 14) then
		say "Happy Valentine's Day!"
	end if
	
else if (m is March) then
	if (d is 17) then say "Happy I hate my liver day, a.k.a. St. Patrick's Day!"
	
else if (m is April) then
	if (d is 15) then say "Today is Tax day!"
	
else if (m is June) then
	if (d is 4) then say "Happy 4th of July. Let's blow some shit up!"
	
else if (m is October) then
	if (d is 31) then say "Trick or Treat, Happy All Hallows Eve!"
	
else if (m is December) then
	if (d is 14) then
		say "Happy Birthday Sara!"
	else if (d is 23) then
		say "2 Days till Chrismas! I hope you've finished all your shopping."
	else if (d is 24) then
		say "It's Christmas Eve!"
	else if (d is 25) then
		say "Merry Christmas!"
	else if (d is 31) then
		say "Happy New Years Eve! Say goodbye to" & (y)
	end if
end if

Thanks NG for the tune-up on that script. I’m still learning!
I also figured out a nifty script for calculating the age of someone, that I slipped into that script for peoples Birthday’s. It could also be tweaked for anniversaries too…
All you need to do is replace the year in “set birthdate to (year)”


set {year:y, month:m, day:d} to (current date)
--
if (m is May) then
	if (d is 23) then
		set birthdate to (2007)
		set age to y - birthdate
		say "Today is Allison's Birthday, she turns" & age
	end if

Hi soxmonky,

Great stuff. It looks as if you’ll be having some fun with this. :slight_smile:

By the way, I didn’t mean to imply that your own ‘if.else’ layout wasn’t perfectly adequate for the current job. I was just offering the programme-flow tip for general consideration. It only saves a microsecond or two per run here!

Just putting the final touches on a Movie Calendar script, that plays every Friday morning. I want to include it into my main morning script but just skip over it if its not Friday. I’ve been playing around with (currentweekday) but nothing has worked yet.

Movie Calendar is below… (Auto-refresh: Every Week) - Ignore Alerts
https://www.google.com/calendar/ical/pfutdblf1gi8jmfsvroh76f6jg%40group.calendar.google.com/public/basic.ics


set today to (current date)
set today's time to 0
set tomorrow to today + 7 * days
set myMovies to {}
set numberOfMovies to (count myMovies)

set movieHours to hours of (current date)
if movieHours is less than 10 then
	set timeofDay to "Today"
else if movieHours is less than 14 then
	set timeofDay to "This Afternoon"
else if movieHours is less than 18 then
	set timeofDay to "This Evening"
else
	set timeofDay to "Tonight"
end if

tell application "Calendar"
	set futureMovies to every event of calendar "Movies" whose start date ≥ today and end date ≤ tomorrow
end tell
repeat with anEvent in futureMovies
	tell application "Calendar" to set {summary:movieTitle, start date:theStartDate, allday event:theTimes, description:movieNotes, location:movieLocation} to anEvent
	
	set movieSummary to summarize movieNotes in 1
	
	set movieDay to (weekday of theStartDate)
	
	set moviePlots to {", Here is a quick plot synopsis of the film.", ", Here is a little bit about the film.", ", Here is a short plot summary of the movie.", ", Let's take a look at the films synopsis.", ", Here's some details about the movie.", ", Here is some information about the movie."}
	set moviePlot to some item of moviePlots
	
	set theTimes to {"There is a movie entitled,", timeofDay & "You could go see,", "Showing" & timeofDay & ", is,", "You might want to see,", "There is a new film titled,", "Opening this " & movieDay & ", is,", timeofDay & "You might be interested in,", "Now showing,", "Now playing,", "Playing this " & movieDay & ", is,", "Playing " & timeofDay & ", is,"}
	set theTime to some item of theTimes
	
	set the end of myMovies to theTime & movieTitle & ", in." & movieLocation & moviePlot & " . " & movieSummary
end repeat

set numberOfMovies to (count myMovies)
if (numberOfMovies is less than 1) then
	set firstGreetings to {"There are no new movies opening" & timeofDay, "I was unable to find any new movies opening this weekend.", "Looks like a slow weekend for Holywood. There is no new movies premiering" & timeofDay, "There is nothing new showing at the movie theater this weekend.", "You might want to watch something on Netflix" & timeofDay & ", there is nothing new at your local theater."}
	set firstGreeting to some item of firstGreetings
	say firstGreeting
else if (numberOfMovies is equal to 1) then
	set secondGreetings to {"Here's a quick look at whats at the movies, " & timeofDay, "Let's see whats playing at the movie theaters this weekend., I have found one new movie opening " & movieDay, "Here's what is being released this weekend at the movies.", "There is one new movie premiering.", "Who's up for a movie this " & movieDay}
	set secondGreeting to some item of secondGreetings
	say secondGreeting
	delay 1
	say item 1 of myMovies
else
	set thirdGreetings to {"I've found" & numberOfMovies & "new movies you might be interested in seeing this " & movieDay, "There are" & numberOfMovies & " new movies opening this weekend.", "Now showing at a movie theater near you!..." & numberOfMovies & "new movies have just been released" & timeofDay, "I have found " & numberOfMovies & " movies opening" & timeofDay, "Here is a look at whats playing " & movieDay & " at the movie theater.", "Who's up for a movie, " & timeofDay & "There are " & numberOfMovies & "new releases."}
	set thirdGreeting to some item of thirdGreetings
	say thirdGreeting
	delay 1
	repeat with thismovie in myMovies
		say thismovie
		delay 0.6
	end repeat
end if

if (numberOfMovies ≥ 1) then
	say "Check online for" & timeofDay & "'s showtimes, trailers, movie reviews & tickets."
	
set theURL to "http://trailers.apple.com/trailers/showtimes/"
	tell application "Safari"
		activate
		try
			tell window 1 to set current tab to make new tab with properties {URL:theURL}
		on error
			open location theURL
		end try
	end tell
end if

Does anyone know if theres away to incorporate CalendarLib into this script to make it go faster?
http://macscripter.net/viewtopic.php?id=44523

For some reason the allday property wasn’t included in CalendarLib’s event info, but you should be able to change this:

tell application "Calendar"
	set futureMovies to every event of calendar "Movies" whose start date ≥ today and end date ≤ tomorrow
end tell
repeat with anEvent in futureMovies
	tell application "Calendar" to set {summary:movieTitle, start date:theStartDate, allday event:theTimes, description:movieNotes, location:movieLocation} to anEvent

To this:

set theStore to fetch store
set theCal to fetch calendar "Movies" cal type cal local event store theStore -- change to suit
set futureMovies to fetch events starting date today ending date tomorrow searching cals {theCal} event store theStore
repeat with anEvent in futureMovies
	set theId to event identifier for event anEvent
	tell application "Calendar" to set {summary:movieTitle, start date:theStartDate, allday event:theTimes, description:movieNotes, location:movieLocation} to event id theId

And add a use script “CalendarLib” line.

Thanks Shane!

Any ideas on how to apply it to the original Calendar script not just the movie one? I’ve tried with very little success :frowning:

I can’t keep up. Give me a message number, or post it again.