Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Create 'pre-alarmed' events in iCal' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Create 'pre-alarmed' events in iCal
Authored by: mark hunte on Dec 30, '05 09:54:02AM
Thanks for the Hint, I'm mostly do not like to add 3party apps to enhance my apple apps. You can do this in Applescript for those of you do not want 3party apps.

This is a cut down of an old script, the original asked for the date you wanted to put the event on and Description and notes et. for the event. I have cut it down here just to show the set alarm part for the new event.

Save it to you applescript menu or use it with one of the hotkey apps. It will make a new event with the alarm set for minutes or hours, you choose. Also you choose which cal.

I do not in any way suggest this is a better way of doing it, and look forward to see what else comes out of Robert Blum's iCalFix. Maybe apple will look at iCalFix and pull their finger out, because there really should be an option set in the prefs for this.

set iCalendars to {}

set theCals to {}

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

set theyear to (year of (current date)) as string

display dialog "Enter Minutes or Hours before event to sound alarm(blank for no alarm): " default answer "1" buttons {"Minutes", "Hours", "Cancel"} default button 1
copy the result as list to {theAlarmTime, button_pressed}

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 application "iCal"
  activate
  set theEvent to make event at end of events of currentCal -- with properties {start date:theDate, end date:endDate, summary:theSummary, description:"entry by : " & theSStaffname & " on " & timestamp})
  if theAlarmTime is not "" then
    if button_pressed is equal to "Hours" then
      set theAlarm to (theAlarmTime as integer) * -60
    end if
    if button_pressed is equal to "Minutes" then
      set theAlarm to (theAlarmTime as integer) * -60 / 60
    end if
    make new sound alarm at end of sound alarms of theEvent with properties {trigger interval:theAlarm}
    
  end if
  tell application "iCal"
    show theEvent
  end tell
end tell 

mh

[ Reply to This | # ]