what i want to figure out is how to send a String to iCal 5 on 10.7 which is interpreted the same way as creating a quick event, as if you press CMD+N with iCal in focus and then just type "tea at 5" into the popover.

a simplistic sketch (which doesn't work):

on handle_string(theString)
    tell application "iCal"
        make new event with theString
    end tell
end handle_string

i'm comfortable with programming but never done anything with AppleScript. Is there a reference for application commands?


this works and it's not even slow, the only caveat is that it breaks the clipboard:

on handle_string(theString)

    tell application "LaunchBar"
        perform action "Copy" with string theString
    end tell

    tell application "iCal" to activate

    tell application "System Events"
        keystroke "n" using {command down}
        keystroke "v" using {command down}
        keystroke return
    end tell

end handle_string

it's sort of finicky to use the clipboard in a script? i can't figure out how to temporarily hold the clipboard content in a variable, and then set the clipboard back to it. i'll accept your answer if you help me with that.

  • 1
    Is the existing LaunchBar calendar integration insufficient? You just type the name of the calendar, a space, and then the event. For example, to add your event to my iCal calendar called "Family" I just type family tea @ 5pm and poof, there's an even called "tea" at 5pm the same day (if I do it before 5pm) or the next day (if it's already past 5pm). This LaunchBar help page describes it: obdev.at/resources/launchbar/help/WorkingWithCalendars.html Jul 27, 2011 at 3:29
  • huh, well sort of overlooked this... nice!
    – Jakob
    Jul 27, 2011 at 11:13

1 Answer 1


Here's a script that lets you restore the clipboard:

set oldClip to the clipboard as string --save the old clipboard
set the clipboard to "hello world" --put your stuff in the clipboard
log (the clipboard) --do your stuff here
set the clipboard to oldClip as string --restore the old clipboard
  • hehe, yes i tried that. the clipboard seems to be really sensitive about who makes these calls though, i'm seeing errors in the console like this: 27.07.11 04:33:16,733 LaunchBar: NSAppleScript Error -1728: LaunchBar got an error: Can’t get clipboard. (Range: 0, 0) (Application: LaunchBar). So the non-trivial part would be, where do i put these commands in the context of my script?
    – Jakob
    Jul 27, 2011 at 10:47
  • That error shows that LaunchBar is causing problems. Try saving your stuff in the clipboard from outside of the tell application block. Jul 27, 2011 at 14:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .