Page 1 of 1

iCal ToDo Applescript

Posted: Wed Dec 28, 2005 9:43 pm
by Smoohova
I am really enjoying the ical applescript that comes with the the growl app and displays today's events. I was wondering if anyone can write a script that displays todos that are NOT completed?

Posted: Wed Jan 04, 2006 3:59 pm
by Diggory
Here you go:

Code: Select all

--	An applescript that shows uncompleted todos from iCal as growl notifications.


set myAllNotesList to {"ToDos"} as list
set appName to "AppleScript iCal ToDo Notifier"
tell application "GrowlHelperApp" to ¬
	register as application appName all notifications myAllNotesList default notifications myAllNotesList icon of application "iCal"



tell application "iCal"
	set allCalendars to every calendar
	repeat with calIndex from 1 to number of items in allCalendars
		set thisCal to item calIndex of allCalendars
		
		tell thisCal
			--			get properties
			
			set allToDos to every todo
			repeat with todoIndex from 1 to number of items in allToDos
				set thisToDo to item todoIndex of allToDos
				tell thisToDo
					
					try
						if completion date is equal to 0 then
						end if
						
						--	If we get this far, then there is a completion date; therefore the todo is completed
						--   log ("finished todo")
						
					on error
						--	If we are thrown out due to an error, then there is no completion date;  
						-- 	therefore the todo is still outstanding
						--	log ("unfinished todo!")
						
						set toDoSummary to summary
						set toDoDesc to description
						
						try
							
							if toDoDesc is equal to "" then
								set toDoDesc to " "
							end if
						on error
							set toDoDesc to " "
						end try
						
						
						tell application "GrowlHelperApp" to ¬
							notify with name "ToDos" title toDoSummary description toDoDesc application name appName
						
					end try
					
					
				end tell
			end repeat
			
		end tell
		
	end repeat
	
end tell

Posted: Thu Jan 05, 2006 2:16 am
by The_Tick
Woah, Diggory is alive.

Sweet

Posted: Thu Jan 05, 2006 5:48 am
by Smoohova
Good script, just what I was looking for...

Posted: Thu Jan 05, 2006 12:12 pm
by Diggory
Yes, sorry Tick, sort of fell of the edge of the world last year, haven't really touched xcode for about 6 months.

Posted: Thu Jan 05, 2006 3:03 pm
by The_Tick
Diggory wrote:Yes, sorry Tick, sort of fell of the edge of the world last year, haven't really touched xcode for about 6 months.

haha, it's alright, just glad you're ok. So what's new?

Posted: Thu Jan 05, 2006 8:33 pm
by Diggory
Very little - I've basically been slacking for the last six months. Just turned 30 though (sigh...)