Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

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
share|improve this question
    
@Steve Thanks for adding that tag!! –  daviesgeek Jul 21 '11 at 18:30
    
Glad I could help since I just gained the privilege to retag posts. –  Steve Moser Jul 21 '11 at 18:32
    
Yeah...I can't create tags yet. :-( –  daviesgeek Jul 21 '11 at 18:36
    
what's the question? Does the script not work? –  Joel Spolsky Jul 21 '11 at 18:40
1  
The 3rd comment in this thread on cocoaforge (by "stib") (cocoaforge.com/viewtopic.php?f=6&t=20460) has a variation of your script which uses an idle handler. He even commented the script to explain why each part is there and what it's doing. It's been some time now since I used his script, but, if I recall correctly, it did work well, and it was fairly easy to modify it to work with most other apps. –  joelseph Aug 20 '11 at 18:05
show 2 more comments

1 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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.