Skip to Content

AppleScript: Print daily iCal agenda

If you use iCal to store you important dates and events, and use it on a regular basis without syncing events via an iPod, iPhone, or other device, then you know how frustrating it can be when you forget about an appointment or event. I'm going to show you a way to automatically print your daily iCal agenda with a simple AppleScript. You can set this script to run when your Mac starts up so you never miss an appointment!


Continue reading to learn how to create this AppleScript.

Creating the Script

Open Script Editor.app (it can be found in /Applications/AppleScript). When you have the application opened, type (or copy / paste) the entire AppleScript below.

tell application "iCal"
view calendar at (my (current date))
switch view to day view
activate
tell application "System Events"
keystroke "p" using command down
delay 1 -- (seconds)
keystroke return
delay 2 -- (seconds)
keystroke return
end tell
quit
end tell

When you are finished, your script should look similar to the one below.



Saving the script

You can save this script as an application by clicking File > Save As, and choosing "Application" from the "File Format" drop-down box. Type a name and location for your script to be saved and then click the "Save" button.



Running the script

To run this script, you can double-click on the application that you just created or you can drag it into the dock for easy clicking (or right-click on the icon in the dock and select "Open at Login" to have your script run when you login to your account).

When the script runs, it will open iCal, set the view to the current date, and will then print the current view. Normally, this would take a couple minutes to do by hand, but you can now have an iCal agenda quickly printed off.

Additional notes
  1. This script assumes that you are using either Mac OS X "Tiger" (version 10.4) or "Leopard" (version 10.5). I have yet to test this on 10.3 or below, but it may work on older versions of Mac OS X.
  2. In order to use this script, you must enable "GUI Scripting." To do this, open "AppleScript Utility" in the /Applications/AppleScript directory. Then check the "Enable GUI Scripting" checkbox.


Categories

Features How-tos

var digg_url = 'http://digg.com/apple/TUAW_Use_an_AppleScript_to_have_iCal_deliver_a_daily_agenda'; If you use iCal to store you...
 

Add a Comment

*0 / 3000 Character Maximum

15 Comments

Filter by:
kassis

Tried it out and it works like a charm.
the "print" option in iCal gives me the same page, so is the advantae that I can have this spript print the daily list automatically, or am I missing somehting?

July 22 2008 at 4:49 PM Report abuse rate up rate down Reply
Charles

I have done similar with a different script I found in one of the Apple tips message boards (then I set an event with an alarm to run it on weekdays.)

I have tried to modify it to do a couple of things, and that's where I'm running into difficulty:

1. I want it to uncheck a calendar (I created one called "invisible" so these events don't show up as part of the day's activities.) -- I can't figure out how to tell Applescript how to go into the subwindow that the list of calendars is in.)

2. I want to make sure it always selects the correct printer, but when I tell it to "click pop up button 1," it selects the print settings pulldown, instead of the printer list pulldown above it. (So right now, I just set the inkjet as the default printer, and it usually goes to the right place.)

It really seems silly that iCal is not recordable ... for novices like me it is a great option, because I can run something just to find out how the API names the buttons/pulldowns/pop ups etc.

June 26 2008 at 7:33 AM Report abuse rate up rate down Reply
numlock

Never posted a script so i hope this comes out right. Anyway this would print out the day view as a pdf in the folder ical prints its pdfs and saves its backups.

You could then add a folder action to that specific folder to look for pdf´s created today and add that pdf as an attachment to an outgoing mail to the email address of your choice


set todaysDate to (current date)
set {d, m, y} to {day, month, year} of todaysDate

set yearString to text -2 thru -1 of ("0" & (y mod 100))

set monthList to {January, February, March, April, May, June, July, August, September, October, November, December}
repeat with i from 1 to 12
if m = (item i of monthList) then
set monthString to text -2 thru -1 of ("0" & i)
exit repeat
end if
end repeat

set todaysDate to " - " & d & "/" & monthString & "/" & yearString

tell application "iCal" to activate
tell application "System Events"
tell process "iCal"
keystroke "t" using command down
keystroke "p" using command down
delay 3
keystroke return
delay 5
delay 5
click menu button "PDF" of window "Print"
perform action "AXPress" of menu item "Save as PDF…" of menu 1 of menu button "PDF" of window "Print"
delay 2
keystroke "iCal" & todaysDate
keystroke tab
keystroke return
keystroke return
end tell
end tell

April 29 2008 at 5:35 PM Report abuse rate up rate down Reply
1 reply to numlock's comment
geddy76

I had written something very similar to that a month ago. However, no matter what I did, whenever I got to the part where the script was looking to access the Print PDF menu, it crapped out and gave me the NS-4 error (or whatever it is). Just tested yours (in Tiger) and got the same. Which is why I went the Automator way. It still summarizes to email, but not near as nicely as the PDF.

April 30 2008 at 9:12 AM Report abuse rate up rate down Reply
norman Ferguson

@justin - the only problem is that your method does not find recurring events (and I have yet to fond any method that does).

April 28 2008 at 10:54 PM Report abuse rate up rate down Reply
dan

love it!

keep the applescript tips coming!

April 28 2008 at 3:38 PM Report abuse rate up rate down Reply
Aaron Davies

"You can set this script to run when your Mac starts up" -- you shut down your Mac?

April 28 2008 at 2:42 PM Report abuse rate up rate down Reply
norman Ferguson

@geddy76 - unfortunately, 10.5's iCal Automator 'Event Summary' action differs significantly from 10.4 Tiger's. And I have not (yet) found an easy way to find recurring events whose recurrence = today.

Still working on it.

April 28 2008 at 12:24 PM Report abuse rate up rate down Reply
2 replies to norman Ferguson's comment
VA

I confirm, the automator version does not work in Leopard.
This is why I have been looking for an Applescript version...

April 28 2008 at 8:23 PM Report abuse rate up rate down Reply
justin turner

the way to do this in leopard is:

Get specified iCal items, and select the calendar you want.

Filter events in iCal whose start date is today.

Event summary so you get all the details of the events.

New Mail message with what you want.

Send outgoing messages.

jt

April 28 2008 at 9:47 PM Report abuse rate up rate down Reply
Mike

Actually, you could take this a step further and create a reoccurring task in iCal that would kick off early in the morning (say 5 or 6 am) and run this applescript - printing your agenda.

Then as you run out the door for the day, you have a printed agenda waiting for you!

April 28 2008 at 11:40 AM Report abuse rate up rate down Reply
norman Ferguson

Very nice, indeed.

Now let's take it up a notch. Show us how to replace the block with a way to email the day's events to a particular email address.

Thanks!

April 28 2008 at 11:12 AM Report abuse rate up rate down Reply
3 replies to norman Ferguson's comment
Buy an ad here

Hot Apps on TUAW

Tweets

© 2012 AOL Inc. All Rights Reserved.