Skip to content

Instantly share code, notes, and snippets.

@jondkinney
Last active December 13, 2015 18:58
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 jondkinney/4958761 to your computer and use it in GitHub Desktop.
Save jondkinney/4958761 to your computer and use it in GitHub Desktop.
Launch an app if it's not already launched (and make sure it's focused after launch). Otherwise show/hide it if it's already launched. Could probably be improved...
set appName to "Sparrow"
set startIt to false
tell application "System Events"
if not (exists process appName) then
set startIt to true
else
if frontmost of process appName then
set visible of process appName to false
else
set frontmost of process appName to true
end if
end
end tell
if startIt then
tell application appName to activate
delay .1
tell application "System Events"
set visible of process appName to true
set frontmost of process appName to true
end tell
end if
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment