How to create Growl notifications for FCE

applescriptfinal-cut-expressgrowl

I found this script online somewhere and I'm trying to make it so that it constantly checks to see if Final Cut Express is rendering and when it finishes rendering, it displays a Growl notification.

EDIT: My question is: How do I get the script to constantly check to see if FCE is rendering and once it's done rendering, display a notification? The script works to display the notification, now how do I get it to work right?

EDIT: I tried using an idle handler. It didn't work, but maybe I'm not using the idle handler right.

Here's the code for the script:

tell application "System Events"
    tell application process "Final Cut Express HD"
        set windowList to get name of every window
    end tell
end tell


if windowList contains missing value then
end if

tell application "GrowlHelperApp" -- ** the daemon that is behind the scenes
    -- Make a list of all the notification types that this script will ever send: 
    -- ** They really mean "ever" or you'll have to reregister.
    set the allNotificationsList to {"Render Complete"}
    -- , "Another Test Notification"} 
    --** Enable another notification

    -- Make a list of the notifications that will be enabled by default. 
    -- ** We'll see shortly that a note must be enabled and the user can disable it.
    -- Notifications not enabled by default can be enabled later in the 'Applications' tab of the growl prefpane.
    set the enabledNotificationsList to {"Render Complete"} -- ** just one turned on, the other not.

    -- Register our script with growl.
    -- You can optionally (as here) set a default icon for this script's notifications.
    -- ** Theoretically, you only have to register once, but there is absolutely no harm in doing
    -- it every time the script runs, i.e., leaving this line in your script.
    register as application "Final Cut Render Complete Script" all notifications allNotificationsList default notifications enabledNotificationsList icon of application "Final Cut Express HD"

    --  Send a Notification...
    -- This one will appear because it was enabled by default.
    notify with name "Render Complete" title "Render Complete" description "Your Render has Finished." application name "Final Cut Render Complete Script"

    -- This one will not appear -- it wasn't enabled by default so the user has to turn it on in the 'Applications' tab of the Growl prefpane to see it.
    -- Take out the comments to enable it.
    --notify with name "Another Test Notification" title "Another Test Notification  " description "Alas  you won't see me until you enable me yourself..." application name "Final Cut Render Complete Script"
end tell

Best Answer

Did you save the script with the idle handler as a .app file with the "Stay Open" checkbox selected in the Save dialog?

This is required for the code within the idle handler to be run "on idle", else it won't run at all. Save it that way and try again.

You're checking windowList for missing value. This sounds like a condition where no FCE windows are open. If you want the block where you're scripting Growl to execute, it should be within the if statement, not after.

Also, depending on what version of Growl you're using, it might respond to one of "Growl" (v1.3+) or "GrowlHelperApp" (v<1.3), but not the other. To future-proof your script, replace

tell application "GrowlHelperApp

with the following:

tell application id "com.Growl.GrowlHelperApp"

All versions of Growl respond to that.

The block of code you have that triggers Growl looks like you modified their example, and from your comments it sounds like that's working fine.