Running AppleScripts

When you’ve selected an AppleScript, it can be run directly from LaunchBar by pressing Return. To open the script in AppleScript Editor instead, press Shift-Return. Running AppleScripts can be turned off in the Actions pane of LaunchBar Preferences.

Passing string parameters

To pass parameters to your AppleScript simply implement a handler named handle_string(). You can then pass arbitrary strings to this script via LaunchBar by selecting the script and pressing the space bar or by selecting the script as the target of a Send to… operation.

Example

on handle_string(theString)
    say theString
end handle_string

Passing files and URLs as arguments

You can pass file paths or URLs to AppleScripts either via drag and drop or via LaunchBar’s “Send to…” functionality. Files will be passed to the script’s open() handler, URLs will be passed to the handle_string() handler.

Drag and drop: Select the desired AppleScript in LaunchBar and drag items e.g. from Finder onto that script. Choose “Send to…” from the pop-up menu or hold down the Command key during the drag to pass the dragged items immediately.

Send to: Select a file or URL in LaunchBar, then press the Tab key to trigger the “Send to…” action. Now select the desired AppleScript and press Return.

Running scripts in background

By default, LaunchBar runs AppleScripts in foreground, i.e. you cannot perform any further action in LaunchBar until the script has finished executing.

You can optionally run specific scripts in background by opening them with Option-Return.

Running AppleScripts in background doesn’t work with scripts that require user input in dialogs.