As the title says, I'm looking for a way to run an Automator workflow (or a shell script) when I launch a specific application. When I shut down the application, I want to run another workflow/shell script. How do I achieve this?
Any help is much appreciated!
Best Answer
To keep tracking if an app is running you need to use a background loop. I don't know if there is another method but this will work, although it will eat a little bit of your memory. The loop will keep waiting until you open the application, and then it will wait for you to quit.
Save your workflow as an application and set it to run on startup. As your first action run an Applescript like this:
you can set other actions after this or just use applescript.
At the end of the workflow place another action running Applescript:
Again you can set other actions below.
Let me know if you have specific goals and we can work to improve this workflow.