When "App" closed then open "file" script needed....

Hi All. Hopefully someone will be able to help me. I am completely new to scripting - in fact I am not a fan it as it sends my brain into meltdown however I know others think differently and I bow to you. Grovelling over.

I am a cameraman for a news broadcaster and we often do lives by connecting our camera’s to the mac and feeding pictures back to base via a software streaming app. To do this we have to physically change the settings on our cameras to lower resolution and one only channel of audio. Often when in a rush (we are a lot sadly) we can forget to reset the camera back again. What I am looking for is a way so whenever the streaming software is quit a .pdf or .jpg pops up on the screen immediately to remind us (me) to switch the camera back again.

I presume this can be scritped but have no idea where to start. I hope that is enough for someone to point me in the right direction.

Thanks

flooperman

This can definitely be done and a simple dialog box that won’t go away until you acknowledge it would be the messenger (even frantic beeping or a voice if you prefer). To accomplish this, you need to detect that the streaming app is no longer running. What’s the name of the app?

Wow. A beeping box would be great. Presumably I can customise what the box says too? The app is called ‘Encoder’ (Encoder.app)

Model: MacBookPro
Browser: Safari 533.22.3
Operating System: Mac OS X (10.5)

What you need is called an “on idle” script – not the only way, but most direct. Something like the script below. If you’re not familiar with this board, you get the script below into your script editor by clicking on the blue link just above the script that says “Open this scriptlet in your editor”.

In your AppleScript Editor make the changes from "ShareTool " which I used for testing to your app name and location in each of the places indicated. Save it as an Application (the drop down menu below the window’s main pane) and if it is not already checked, check “Stay open”. Save it to your desktop for easy testing.

This script application wants to start yours after reminding you to switch camera settings, but to quit, you quit yours streaming app and then when this app begins its nag, quit it in the dock. Done.


-- When this AppleScript app is run, it reminds you to adjust, and then runs your application.
on run
	tell application "Finder"
		-- an initial reminder...
		set B to button returned of (display dialog "Have you set up the camera?" buttons {"No", "Yes"})
		if B is "Yes" then
			-- clicking the Yes button opens your application.
			-- You need to replace my example with an alias to yours.
			open alias "Macintosh HD:Applications:ShareTool.app:"
		else -- this application just quits in two seconds. Run it again to continue.
			display dialog "Quitting Now" giving up after 2
			tell me to quit
		end if
	end tell
end run

on idle -- this checks every 3 seconds to see if your app is still running. You need to put its name in the line below.
	tell application "System Events"
		if not (exists process "ShareTool") then
			beep 3
			say "Adjust the Camera Now. Quit me to get me to shut up."
			-- just quit from the icon in your dock.
		end if
	end tell
	return 3 -- this is in seconds, on idle will repeat every 3 sec.
end idle

on quit
	tell application "Finder"
		activate
		-- a final warning.
		display dialog "Be sure to readjust the camera!" buttons {"Done"} default button "Done"
	end tell
	continue quit -- this line must be here.
end quit

Enjoy

Thats Brilliant. Thank you. I have tried playing around now I understand how it flows but its not that simple to combine actions. Is it possible to combine the idle and quit sections so there is only one level of nagging when we quit the app.

What would be most effective for us is a flow as follows:

Start up as written.

When we quit the Encoder.app

  1. the warning beeps sound

  2. the nag screen appears

  3. the mac reads the nag screen on a repeat (as you have written.)

  4. there is a done/quit button which stops the nag and quits the script at the same time. (so we don’t have to quit from the dock)

I hope that makes sense. Sorry to be a pain.