Skip to content

Instantly share code, notes, and snippets.

@joshuarudd
Last active November 27, 2015 18:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshuarudd/88dbce6f9426f5e600a4 to your computer and use it in GitHub Desktop.
Save joshuarudd/88dbce6f9426f5e600a4 to your computer and use it in GitHub Desktop.
set quitlist to {"Tweetbot", "Calendar", "Messages", "Skitch"}
set exceptionTriggerList to {"Skype"}
tell application "System Events"
set activeAppName to name of the first process whose frontmost is true
end tell
set exceptionRunning to false
repeat with exceptionName in exceptionTriggerList
if exceptionRunning is false and application exceptionName is running then
set exceptionRunning to true
end if
end repeat
if exceptionRunning is false then
repeat with appName in quitlist
set hasOpenWindow to false
tell application "System Events"
if exists (window 1 of process appName) then
#display dialog (appName as string)
set hasOpenWindow to true
end if
end tell
if (activeAppName as string) is not (appName as string) and application appName is running and hasOpenWindow is not true then
tell application appName to quit
end if
end repeat
end if
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment