We talk about iCal once in a while. Did you know that an iCal alarm can launch an AppleScript? A recent comment from reader Zach (and subsequent replies) made us think that this tip might be of use to anyone who hasn't considered the possibilities.
When you schedule an alarm in iCal, one of the options for the alarm is "Run script." If you select "Other..." from the script selection dropdown, you can choose any AppleScript you want to launch. Then you just tell the alarm when to go off and your script will run.
Considering that AppleScript can control quite a few of the applications on your mac, and that iCal can handle repeating events, the possibilities are wide open. You could do something as simple as schedule applications by putting the following into a script in Script Editor and saving it as a regular script:
tell application "Safari" to activate
and another one...
tell application "Safari" to quit
to quit. Of course, you could then add to the scripts to have Safari navigate to certain pages as well. And you could launch as many apps as you want in the same script. Anything you can do with AppleScript, you can schedule. For more Terminal-savvy readers, Applescript's "do shell script" command allows for an even wider range of possibilities. You can even get user interaction with a "display dialog" command. I'm sure there's someone here who could have a blast with this.













Reader Comments (Page 1 of 1)
4-14-2008 @ 7:22PM
PCheese said...
Automatically mute your sound volume before class!
http://external.pcheese.net/icalmutevolume/
(It's funny that I just yesterday happened to write that article for students in the dorm.)
Reply
4-14-2008 @ 8:07PM
jsw said...
Unfortunately, the migration from iCal in Tiger to iCal in Leopard really borked all of my timed scripts. Most of them seem to be working now, but not all. Any wisdom on this front would be truly appreciated.
P.S. An alarm script is the only way to get Growl Notifications of events or to-dos at this point.
Reply
4-14-2008 @ 9:21PM
Josh said...
Wow this is fantastic. I am very unfamiliar with Applescript but use one every day. Actually it was built on the one I found on this website, it's just a simple app launcher. Everyone morning I launch all the programs I use at work, I moved it to a folder in a stack for easy access on my dock. BUT NOW I don't even have to do that which is great!
I must say one issue I ran into when I went to set this up was that when I selected Run Script I couldn't then select my script, I had to change the Alarm option to Open File then select my script. Is this weird?
Reply
4-14-2008 @ 9:32PM
Brett Terpstra said...
Yes, that seems odd. Are you on Tiger or Leopard? I'd have trouble vouching for Tiger, but I can testify that the screenshot in the article is exactly what I see when "Run script" is chosen, and that clicking where it says quitsafari.scpt gives me a dropdown, the last option of which is Other… (to select a custom script).
4-14-2008 @ 9:41PM
JoshK said...
Yes I am running Leopard, up-to-date and everything. It is strange,
I'll select "Run Script" then it takes me to the finder directory. I
navigate to the folder that has my script but it is grayed out
indicating it can't be selected. I could send a screenshot if I knew
where to. Sadly, I can't just drop it into this comment box.
Reply
4-14-2008 @ 9:41PM
JoshK said...
Yes I am running Leopard, up-to-date and everything. It is strange,
I'll select "Run Script" then it takes me to the finder directory. I
navigate to the folder that has my script but it is grayed out
indicating it can't be selected. I could send a screenshot if I knew
where to. Sadly, I can't just drop it into this comment box.
Reply
4-14-2008 @ 10:58PM
Maxwell said...
If you could HIDE these timed events in iCal that would be great. But I needed a daily reminder and did not want it cluttering up iCal - so I wrote an AppleScript to pop up a daily reminder and saved it as an application that I added as a login item. (Well, actually, two AppleScript apps, but the second one just pops up the reminder dialog.) I use Dock Dodger to keep it out of the dock, and now it just pops up every day regular as clockwork, but otherwise is not anywhere to be seen.
Reply
4-14-2008 @ 11:18PM
jsw said...
Hiding them is easy -- just put them all into one calendar (I use "Zcript" and then uncheck the calendar in the left hand column. Presto! It's gone.
4-15-2008 @ 2:14AM
Joe B said...
I actually use something like this to do backups of important document folders in between full system backups.
I use an Automator action instead of AppleScript because it's faster for me to make quick changes as necessary. I just set it up to copy specific folders to my external drive at a regular time everyday.
It's a crude solution, but it saves me the time and trouble of doing a full system backup when I know that there are only a handful of files that are being changed daily. (Obviously I haven't moved up to Leopard and Time Machine yet.)
Reply
4-16-2008 @ 2:35AM
Scott Reynolds said...
If you prefer scheduled predictability for updating your iTunes podcasts, try this:
tell application "iTunes" to updateAllPodcasts
Reply