Created
January 21, 2021 13:10
-
-
Save VincentSit/1cd7ec6d3f2533f65a699bb5cbb6103e to your computer and use it in GitHub Desktop.
AppleScript to Show or Hide Application. Launch it if not running.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set appName to "Xcode" | |
tell application appName | |
if it is not running then | |
activate | |
else | |
tell application "System Events" | |
set activeApp to name of first application process whose frontmost is true | |
if visible of application process appName is false or (not (exists (window 1 of process appName))) or (appName is not in activeApp) then | |
tell process "Dock" | |
tell UI element appName of list 1 | |
click | |
end tell | |
end tell | |
set visible of application process appName to true | |
else | |
set visible of application process appName to false | |
end if | |
end tell | |
end if | |
end tell |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Some special cases
Finder
Visual Studio Code
iTerm2