Description: Quick way to add to todo's to iCal.
Requirement: Mac OS 10.3+ and Satimage.osax

You can add todo's is the following forms:

[days] [alarm] [summery]
5 Order train ticket (no alarm)
5 1 Order train ticket (with alarm one day before)
5 0 Order train ticket (with alarm the same day)

Use something like Quicksilver or iKey to add shortcuts/triggers to the script.

Open in the Script Editor

-- Script Start
(*
  Quick way to add to todo's to iCal.
  Modified versions of the QSiCalScripts from
  http://www.hawkwings.net/2006/02/04/applescripts-for-ical-events-and-to-dos/
  2007-03-26 by Fredrik Jonsson <mailto(colon)fredrik(at)combonet(dot)se>
  home page <http://xdeb.org/wiki/AppleScript>
*)
 
property theAlarmSound : "Basso" -- Ping, Basso, Sosumi etc.
 
set iCalendars to {}
set theCals to {}
set priList to {"None", "Very Important", "Important", "Not Important"}
set priNums to {0, 3, 5, 9}
 
tell application "iCal"
  set theCals to calendars whose writable is true
  repeat with i from 1 to count of theCals
    copy title of item i of theCals to end of iCalendars
  end repeat
end tell
 
tell me to activate
set theDialog to (display dialog "Make new todo with [days] [alarm] [summery]: " default answer "")
if (button returned of theDialog is "Cancel") then return
set theResult to the text returned of theDialog
 
set theToDo to find text "(([0-9:]+)[ ]+)?(([0-9]+)[ ]+)?(.*)" in theResult using {"\\2", "\\4", "\\5"} with string result and regexp
 
set theDaysTo to string 1 of theToDo
set theAlarmTime to string 2 of theToDo
set theSummary to string 3 of theToDo
set theDescription to ""
 
set thisDate to current date
 
tell me to activate
set theChoice to choose from list iCalendars with prompt "Choose the Calendar to use" OK button name "Choose" without multiple selections allowed and empty selection allowed
 
if theChoice is not false then
  set theCalChoice to item 1 of theChoice
end if
 
set theCalName to theCalChoice
 
-- Run through our Calendar list and find the iCal id of the chosen Calendar 
set i to 1
repeat with anitem in iCalendars
  if item i of iCalendars is equal to theCalName then
    set theNum to i
    exit repeat
  end if
  set i to i + 1
end repeat
 
set currentCal to item theNum of theCals
 
tell me to activate
set theChoice to choose from list priList with prompt "Choose the Priority" OK button name "Choose" default items {"None"} without multiple selections allowed and empty selection allowed
if theChoice is not false then
  set thePriChoice to item 1 of theChoice
end if
set i to 1
repeat with anitem in priList
  if item i of priList is equal to thePriChoice then
    set theNum to i
    exit repeat
  end if
  set i to i + 1
end repeat
set thePri to item theNum of priNums
 
tell application "iCal"
  if theDaysTo is not "" then
    set theDate to (current date) + ((theDaysTo as number) * days)
    -- Reset the time of the todo to 00:00 as iCal does.
    set time of theDate to 0
    set theToDo to (make todo at end of todos of currentCal with properties {due date:theDate, priority:thePri, summary:theSummary, description:theDescription})
    if theAlarmTime is not "" then
      set theAlarm to ((theAlarmTime as integer) * 24 * -60) + (8 * 60)
      make new sound alarm at end of sound alarms of theToDo with properties {trigger interval:theAlarm, sound name:theAlarmSound}
    end if
  else
    make todo at end of todos of currentCal with properties {priority:thePri, summary:theSummary, description:theDescription}
  end if
end tell
-- Script Stop
 
applescript/quickicaltodo.txt · Senast uppdaterad: 2007-07-07 15:03 av frjo
 
Recent changes RSS feed Creative Commons License Driven by DokuWiki