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 have an Application created with Automator. Since the application starts a service in the background, I'd like to keep the application open even after the end of the workflow is reached. When the user quits the application, I'd like to execute a command to stop the service. How can I achieve the above?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

I don't know of a way to make a "stay open" Automator app, but you could make a simple "stay open" AppleScript app that can launch an Automator app to start your service, then, when the user quits the AppleScript app, it can launch a 2nd Automator app to stop the service.

Such an AppleScript would look something like this:

on run
    tell application "1st Automator App" to activate
end run

on quit
    tell application "2nd Automator App" to activate
    continue quit
end quit

You could then replace "1st Automator App" with the name of the Automator app that will start the service, and replace "2nd Automator App" with the name of the Automator app that will stop the service.

You would then save the AppleScript as an application with the "stay open" option checked.

Depending on what else your Automator app needs to do, it may be possible to skip Automator altogether and start and stop the service directly in AppleScript.

share|improve this answer
    
Thanks. I've managed to skip Automator completely thanks to your tip. –  Roberto Aloi Sep 1 '11 at 19:28

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.