Final Cut render and growl (applescript) !!!! SUCCESS!

The Growl forums have moved to Google Groups, this forum is read only.

Final Cut render and growl (applescript) !!!! SUCCESS!

Postby typotype2 » Tue Jul 14, 2009 5:47 pm

I finally figured it out. Just copy and paste into scripteditor and save as an app. YOu just run the app after you start a render or export. Now maybe someone can take this and expand it so if you do a render or an export it automatically starts but for now it works for the long renders you don't want to sit around for. Gonna try it out with the iphone client now.


tell application "System Events"
tell application process "Final Cut Pro"
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"}

-- 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 "Script Editor"

-- 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.
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
typotype2
Harmless
 
Posts: 1
Joined: Tue Jul 14, 2009 3:35 pm

Re: Final Cut render and growl (applescript) !!!! SUCCESS!

Postby mannieschumpert » Tue Sep 01, 2009 2:16 am

This is good stuff!

I'm a newbie, though, in both AppleScript and Growl, and am trying to figure out how to get a Growl/Prowl notification at the completion of an export. With the script you have here, I get a "Render Complete" notification well before the export is completed. I figure there is a render process that completes before the export conversion process even starts. Having no other idea what to edit, I tried simply changing all the "Render Complete" references to "Export Complete" ones, which resulted in the script doing nothing.

Any ideas how I can change this script to suit my needs?
mannieschumpert
Harmless
 
Posts: 2
Joined: Tue Sep 01, 2009 1:49 am

Re: Final Cut render and growl (applescript) !!!! SUCCESS!

Postby jared79 » Tue Sep 01, 2009 4:19 am

Dude, this is awesome. It works and is a answer to prayer. Long Renders suck and this is great, so I can walk away. I don't know Apple Script, but can this be done for Compressor/Batch Monitor to say when it is finished? That would be the icing on the cake. Thanks again for sharing.
jared79
Harmless
 
Posts: 1
Joined: Tue Sep 01, 2009 4:17 am

Re: Final Cut render and growl (applescript) !!!! SUCCESS!

Postby stib » Tue Sep 01, 2009 8:44 pm

I've hacked the script a bit, so that it can stay running, and so you can use it with other apps.

The original just used the trick of asking FCP to give a list of the open windows, which it wouldn't respond to while rendering. That worked fine, but the problem was that if you left the script running it would keep notifying whenever the app responded, meaning whenever it was not rendering, meaning all the time.

So I made the test a bit different. It now checks on the CPU usage. If it goes over a threshold it assumes FCP is rendering, and then waits for it to finish, when it will notify you. So this script will stay running in the background and keep checking. You can also use this script to launch FCP (or the app of your choice), so that you can use it whenever you want to run FCP meaning don't have to remember to turn it on. To do this you have to change the false in the second line to true. Then put the script in the dock or your FCP folder and run it instead of running FCP.

To use this with compressor, or any other app, just change the name of the app in the first line. You need to change it to the actual application that is doing the work.

I've pasted the script below, but to get it to work you need to make sure you save it as an application, and you check the Stay Open checkbox in the save dialogue. Otherwise it won't work. It won't work if you run it from within script editor either, because it won't execute the sleep function. So you have to save it and run it. If you're not going to tweak it you can just unzip the attachment and run it.

Code: Select all
property theApp : "Final Cut Pro"
-- the full name of the application we're monitoring

property runTargetApOnStartup : false
-- use this if you want the script to launch the target app on startup. Then you can use this script to start the application to ensure that the script will always be running

property checkinterval : 20
--how long between activiy checks (in seconds). Renders under this amount may not be noticed (which is a feature, not a bug)
--set it to the amount of time it takes you to get bored waiting for a render

property minimumDelay : 5
--the lengths between checks when FCP is rendering - this sets the possible delay between the render ending and the notification.
-- The lower the number the more prompt the notification, but the more processing power the script eats up.

property theThreshold : 85
--the CPU activity, above which we assume that FCP is rendering. You might need a bit of trial and error to get this right

global hasStartedARender

on run
   if runTargetApOnStartup then tell application theApp to activate ---activate the application
   set hasStartedARender to false
   idle --go into the background and check at regular intervals
end run


on idle
   try
      set theAppusage to (do shell script ("ps aux |grep '" & theApp & "'|grep -v 'grep'" as string))
      --what that shell script does is use ps aux to get a list of the running processes,
      --then grep searches for the one with the same path as we specified in theApp property
      
      set theCPU to the third word in theAppusage
   on error
      set theCPU to "0"
   end try
   --the result takes the form User PID CPU Mem etc.. so we want the third term
   
   set thebiggestprocess to 0
   repeat with theprocess in (every paragraph in theCPU)
      --some programs like After Effects have a few other processes that might be running, like the crash reporter. This just chooses the process that is using the most CPU
      if theprocess as number > thebiggestprocess then set thebiggestprocess to theprocess
   end repeat
   set theCPU to thebiggestprocess
   log theCPU
   
   set isdoingsomething to theCPU as number > theThreshold --find out whether FCP is using lotsa CPU
   if isdoingsomething then
      set hasStartedARender to true
      set sleepinterval to minimumDelay --check more
   else
      set sleepinterval to checkinterval
      if hasStartedARender then --FCP is not doing anything any more, but it has been in the past becuse hasStartedARender is true   
         set hasStartedARender to false --reset the render watcher
         growlNotify() --display a notification
      end if
   end if
   return sleepinterval --wait this long until I wake up next
end idle

on growlNotify() --the bit that does the growling
   tell application "GrowlHelperApp"
      set NotificationsList to {"Render Complete"}
      register as application "Render Complete Script" all notifications NotificationsList default notifications NotificationsList icon of application theApp
      notify with name "Render Complete" title "Render Complete" description "Your Render has Finished." application name "Final Cut Render Complete Script"
      
   end tell
end growlNotify
Attachments
renderover.zip
(23.3 KiB) Downloaded 297 times
stib
Harmless
 
Posts: 1
Joined: Tue Sep 01, 2009 7:58 pm

Re: Final Cut render and growl (applescript) !!!! SUCCESS!

Postby mannieschumpert » Thu Sep 03, 2009 4:23 pm

Thanks so much! That's really helpful.
mannieschumpert
Harmless
 
Posts: 2
Joined: Tue Sep 01, 2009 1:49 am


Return to Growl

Who is online

Users browsing this forum: Yahoo [Bot]