This AppleScript lets you quickly check to see if an application is running and “toggle” it on or off. (If it isn’t running, it launches it. If it is running, it quits the application. It’s perfect for quickly opening and closing apps like PasteBot which run as a Menu Extras (a.k.a., menulets) or for apps that run in the background.
To use it, change the property app_Name to the name of the application you’d like to toggle on/off. Save the script as an application and double-click it to toggle the app — or you can trigger it via a keyboard-driven launcher app (like Alfred or LaunchBar). Note: Many launcher apps allow you to pass information to an AppleScript. This will allow you to modify this script to toggle more than one app. See the instructions of your launcher app for details on how to do this!
January 13, 2012
Project Status, Latest Updates, and Comments Collected at:
1.0 INITIAL VERSION
// RECOMMENDED INSTALLATION INSTRUCTIONS:
-- Change the property below for app_Name to the
name of the application you'd like to toggle on/off.
-- Save as an application and trigger via
a keyboard-driven launcher app (like Alfred or LaunchBar).
-- Note: Many launcher apps allow you to pass information
to an AppleScript. This will allow you to modify this script
to toggle more than one app See the instructions of
your launcher app for details on how to do this!
// USER SWITCHES (YOU CAN CHANGE THESE!)
--ENTER THE NAME OF THE APP
--THAT YOU WOULD LIKE TO TOGGLE
--IN THE PROPERTY BELOW...
property app_Name : ""
// MAIN PROGRAM
if appIsRunning(app_Name) then
do shell script "killall " & (quoted form of app_Name)
do shell script "open -a " & (quoted form of app_Name)
// MAIN HANDLER SUBROUTINES
tell application "System Events" to (name of processes) contains appName
New To AppleScript?
- Here's how to use the AppleScripts you find here and -- to make them even easier to use -- here's how run them with simple keyboard shortcuts!
- Be sure to check out other great AppleScripts in the Veritrope.com Code Library -- and share your own AppleScript projects using the quick submission form!