MacOS – Applescript, quit app if other app is quit

applescriptapplicationsmacosplex

I have a (very basic) apple script that I use as a trigger to start and hijack Plex, using Audio Hijack Pro.

tell application "Audio Hijack Pro"
start hijacking session named "Plex"
end tell
tell application "Plex"
    activate
end tell

Where the last three lines just ensure Plex is in the foreground.

Here is where my question comes in. If possible, I would like to extend my script a little; it should keep running while Hijack Audio Pro is hijacking Plex, and quit Hijack Audio Pro if Plex is quit. Does anyone know how to achieve this?

Best Answer

I've only dabbled in Applescript, but would you be able to create a second script that is basically reversed? In English it would look like:

tell Plex to quit
then
tell Audio Hijack Pro to quit