Automating iCal ToDo's with Agents

Hi. The applescript way to add a ToDo to iCal really works for me, because I keep the script around even after deleting the ToDo. The other cool thing is if there is something I want to do that I know I won’t get to until a while, I can save adding it to iCal until later (via an Agent, which I typically configure through Lingon, but I also have the Property List Editor on my Mac.)

I can’t just set an applescript to run on a given day, because if my Mac were off that day it wouldn’t run the next, etc. and I’d have nothing to remind me that a script that puts a ToDo in iCal was left un-run at the designated time.

So I can set it with an if statement saying that if it is (given date) or after tell application iCal. (and have the Agent that runs the applescript have a RunAtLoad parameter).

Obviously, that’s not such a great idea because then I have to write another applescript that deletes duplicate To-Do’s just in case. What I really need is some sort of a way to track if an applescript has been run before.

But it’s an okay temporary solution”or is it?

set theSumm to "Blog about xxxxxxxx"
set theUrl to "xxxxxxxx"
tell application "iCal"
	tell calendar "Trivial"
		make new todo at end with properties {summary:theSumm, url:theUrl}
	end tell
end tell

Above is a template I’ve made for making a ToDo.

set the_date to (the current date)
set the_month to "3"
set the_year to "09"
set the_day to "4"
if short date string of (the current date) is greater than or equal to (the_month & "/" & the_day & "/" & the_year) then
	display dialog "U win"
else
	display dialog "U lose"
end if

Above is the way I would use to check if it is a certain date.

So far as I know, an Agent cannot run multiple applescripts.

There are two ways I know of running an applescript with an Agent:

  1. save the applescript as a “.applescript” file and make the file executable (still not exactly sure what that means) with “chmod +x /pathtofile/theFile.applescript”

  2. save the applescript as a “.scpt” file and make the Agent, but write "osascript " before the path to the “.scpt” file: I don’t know if there’s an advantage of one over the other: I’m a real newbie.

if I add all my “if” statements to one applescript, I run into the problem that I can’t set “the_month” to 2 (or more) different things in different parts of the script.

if I make multiple applescripts, I have to make an Agent for each one:

Though through Do shell script (with defaults write /Users/USERNAME/Library/LaunchAgents/MyAgent Label MyLabel etc.) I can create an entire Agent, automatingProxy-Connection: keep-alive
Cache-Control: max-age=0

t so it has a unique name in the folder that it’s in is not something I know how to do.

Model: MacBook

um.something went wrong with my post towards the end so here’s the part after you see “2)”:

if I add all my “if” statements to one applescript, I run into the problem that I can’t set “the_month” to 2 (or more) different things in different parts of the script.

if I make multiple applescripts, I have to make an Agent for each one:

Though through Do shell script (with defaults write /Users/USERNAME/Library/LaunchAgents/MyAgent Label MyLabel etc.) I can create an entire Agent, but automating the naming of the agents that I automate the creation of”based on what “theSumm” contains for the script that I’m currently working on or some other means of automated unique naming”

is not something I know how to do.

I’m a high school student who needs to get way more organized and I’m trying to use applescript to help me do so :wink:

Model: MacBook
Browser: Firefox 3.0.1
Operating System: Mac OS X (10.5)

Maybe http://macscripter.net/viewtopic.php?id=28427 will help me out. Just saw it on “recent posts.”