AppleScript Support for Growl
About AppleScript Support
AppleScript support is built into Growl; nothing special needs to be done to enable it.
A Note on AppleScript changes in Growl 0.6
You must update your existing AppleScripts for Growl 0.6 In Growl 0.6 AppleScripts must register their notifications every time the script is run — unregistered notifications will not be displayed. See below for an example of registration.
Usage
Basics
To send a Growl notification via AppleScript, you talk to GrowlHelperApp using two commands: register and notify. A script, like an application, must register itself (once, though multiple times is harmless) with Growl before sending any notifications. The full syntax of the register and notify commands can be viewed by opening Script Editor, choosing File → Open Dictionary, and selecting GrowlHelperApp from the list.
Sample AppleScript Notification
tell application "GrowlHelperApp" -- Make a list of all the notification types -- that this script will ever send: set the allNotificationsList to ¬ {"Test Notification" , "Another Test Notification"} -- Make a list of the notifications -- that will be enabled by default. -- Those not enabled by default can be enabled later -- in the 'Applications' tab of the growl prefpane. set the enabledNotificationsList to ¬ {"Test Notification"} -- Register our script with growl. -- You can optionally (as here) set a default icon -- for this script's notifications. register as application "Growl AppleScript Sample" ¬ all notifications allNotificationsList ¬ default notifications enabledNotificationsList ¬ icon of application "Script Editor" -- Send a Notification... notify with name "Test Notification" ¬ title "Test Notification" ¬ description "This is a test AppleScript notification." ¬ application name "Growl AppleScript Sample" notify with name "Another Test Notification" ¬ title "Another Test Notification :) " ¬ description "Alas — you won't see me until you enable me..." ¬ application name "Growl AppleScript Sample" end tell
Once you send the Registration command - your script will appear in the 'applications' tab of the Growl prefpane.

Notifications Using Images
Growl's notify command supports four types of images for notification when using AppleScript:
-
Application Icons
Example:
notify with ¬ name "Some Notification" ¬ title "This is a Notification with an App Icon" ¬ description "We are using an Application Icon..." ¬ application name "Growl AppleScript Sample" ¬ icon of application "Script Editor.app"Note that the ".app" at the end is optional.
-
File Icons
notify with ¬ name "Some Notification" ¬ title "This is a Notification with an File Icon" ¬ description "We are using a File's Icon..." ¬ application name "Growl AppleScript Sample" ¬ icon of file "file:///Users/someone/Growl"See Notes on File Paths for details on how to specify the path to a file icon.
-
Image Files
Supported Types: BMP, GIF, ICNS, ICO, JPEG, JPEG 2000, PNG, PSD, TGA, TIFF
Example:
notify with ¬ name "Some Notification" ¬ title "This is a Notification with an Image File" ¬ description "We are using an Image File..." ¬ application name "Growl AppleScript Sample" ¬ image from location ¬ "file:///Users/someone/pictures/stopWatch.png"
-
Image Data
Supported Types: PICT, TIFF
When you are dealing with raw image data you should use the notify ... Image or notify ... pictImage commands.
Examples:
Carbon apps tend to return PICT
set the PICTdata to my getArtworkFromiTunesRoutine() notify with ¬ name "Some Notification" ¬ title "This is a Notification with PICT Image Data" ¬ description "We are using PICT data..." ¬ application name "Growl AppleScript Sample" ¬ PICTimage the PICTdataCocoa apps tend to return TIFF
set the TIFFdata to my getPhotoFromAddressBookRoutine() notify with ¬ name "Some Notification" ¬ title "This is a Notification with TIFF Image Data" ¬ description "We are using TIFF data..." ¬ application name "Growl AppleScript Sample" ¬ image the TIFFdataIf you're not sure which type you are dealing with then you can look in Script Editor's Event Log. The first four chars of the data will show the type:
Notes on File Paths
For the "notify ... image from location" and "notify ... icon of file" commands Growl accepts any of the following types as 'locations':
- Aliases - the default file reference type in AppleScript.
- Local file:// URLs (as text) - e.g. "file:///Applications/" — n.b. you must have three slashes after the colon — the third represents the root of the filesystem.
- Paths - e.g. "~/Pictures"
Checking if Growl is running
If you want to distribute your scripts, you should check if Growl is running before sending any events to GrowlHelperApp in order to avoid the "Choose Application" dialog.
tell application "System Events" set isRunning to ¬ count of (every process whose name is "GrowlHelperApp") > 0 end tell
Authors
v0.6 (update) — Diggory Laycock — www.monkeyfood.com
v0.5 — Adam Nolley — nanovivid.com










