Full credit to @ghoppe over at Super User for this excellent answer. I'm only duplicating it here because a moderator on Meta suggested that it would be appropriate to do so.
Please note that this solution will suppress Growl when VLC (media player) is running. To make it work for another application (e.g. QuickTime), you'll have to modify the Applescript. If you've tried yourself but still need help, I would suggest posting a question about it over at Stack Overflow.
Original answer follows:
Enter in Applescript Editor, save as application, when saving check the box "Stay Open". Use this new applescript application to launch the VLC application.
Description: It will launch VLC, turn off growl notifications, check every 2s to see if VLC has quit, if so it will turn growl notifications back on and then quit. As a bonus, it will use growl notifications to notify you when growl notifications will be turned on or off.
global Growl_was_Loaded
global VLC_is_Loaded
on run
set Growl_was_Loaded to isAppLoaded("GrowlHelperApp")
set VLC_is_Loaded to isAppLoaded("VLC")
launchVLC()
idle
end run
on idle
set x to isAppLoaded("VLC")
if x and not VLC_is_Loaded then
launchVLC()
else if VLC_is_Loaded and not x then
set VLC_is_Loaded to false
if Growl_was_Loaded then
tell application "GrowlHelperApp" to launch
growl_notify("Growl notifications have been turned ON")
end if
tell me to quit
end if
return 2 -- wait 2 seconds
end idle
on launchVLC()
tell application "VLC" to launch
if Growl_was_Loaded then
growl_notify("Launching VLC… Growl notifications have been turned OFF")
delay 1
tell application "GrowlHelperApp" to quit
end if
set VLC_is_Loaded to true
end launchVLC
on isAppLoaded(app_name)
tell application "System Events"
set app_list to every application process whose name is app_name
if the (count of app_list) > 0 then
set x to true
else
set x to false
end if
end tell
return x
end isAppLoaded
on growl_notify(msg)
tell application "GrowlHelperApp"
set the allNotificationsList to {"Growl Toggler"}
register as application "Growl Toggler" all notifications allNotificationsList default notifications allNotificationsList
notify with name "Growl Toggler" title msg description "" application name "Growl Toggler" icon of application "Automator"
end tell
end growl_notify
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.
Best Answer
You need to download GrowlMail, however every time MacOS X is updated the version of GrowlMail becomes outdated and won't run (under Snow Leopard, at least).
I think that the current version of GrowlMail doesn't work with Mac OS X 10.6.7 at present. Details of why it keeps breaking are here. It is annoying but seems unavoidable.