Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

An AppleScript to quickly launch applications Apps
I find it a bit of a time waster to open up my Applications folder everytime I want to open an application I don't use that often (as in: I don't have it bound to a keyboard shortcut using Keyboard Maestro like I do my more common applications). In KDE on linux I can press Alt-F2 to bring up a box that I can type the name of an executable file and it will load - I wanted something similar on my Mac.

So I wrote this Applescript that will bring up a window so you can type in the name of the application you want to start. Then I improved that so that it saves the applications you run in a list so you get a list of the most recently run applications you used it to launch - plus an "Other ..." option for a new application. You can change the number of entries it saves by changing the number 10 on the first line of the script. I then use Keyboard Maestro to bind it to a key (I use F13).

BTW: I know LaunchBar or some other shareware probably does this along with a whole lot of other things .. but I don't have it and don't need all the other functionality!

Here's the script:

set rememberEntries to 10

set runList to {}
set runListString to "Safari,Address Book,Mail"
set lastRun to "Safari"
set savedTextItemDelimiters to AppleScript's text item delimiters
set AppleScript's text item delimiters to {","}

try
  set lastRun to do shell script "defaults read com.rickosoft.actUp lastRun"
  set runListString to do shell script "defaults read com.rickosoft.actUp runList"
end try

set runList to (text items of runListString & ("Other ..." as list))

try
  set runApp to ¬
  (choose from list runList with prompt ¬
  "Choose Application to activate" default items (last item of runList) ¬
  OK button name ¬
  "Choose" with multiple selections allowed and empty selection allowed)
  repeat with anApp in runApp
    if anApp contains "Other ..." then
      set runNow to text returned of ¬
      (display dialog "Name of Application to activate?" default answer lastRun)
      set lastRun to runNow
      set runApp to runApp & runNow
    else
      set runNow to anApp
    end if
    tell application runNow to activate
  end repeat
  on error
  return "User cancelled"
end try

set outRunApp to {}
repeat with runAppItem in runApp
  if runAppItem as string is not "Other ..." then
    if outRunApp does not contain runAppItem then ¬
    set outRunApp to outRunApp & runAppItem
  end if
end repeat
set outRunList to outRunApp -- Promote/Add the run app to the top of the list
repeat with runListItem in runList
  if runListItem as string is not "Other ..." and (count of outRunList) ¬
  is less than rememberEntries then
    if outRunList does not contain runListItem then set outRunList ¬
    to outRunList & runListItem
  end if
end repeat
set runListString to "\"" & (outRunList as text) & "\""
if outRunApp is equal to {} then set outRunApp to lastRun as list

do shell script "defaults write com.rickosoft.actUp lastRun \"" & ¬
last item of outRunApp & "\""
do shell script "defaults write com.rickosoft.actUp runList " ¬
& runListString

set AppleScript's text item delimiters to savedTextItemDelimiters
return true
[robg adds: This works exactly as described...]
    •    
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)
 
[12,253 views]  

An AppleScript to quickly launch applications | 34 comments | Create New Account
Click here to return to the 'An AppleScript to quickly launch applications' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
An AppleScript to quickly launch applications
Authored by: Akira on Feb 23, '04 11:04:59AM

is it possible to and wouldn't it be more handy if you could give this applescript the interface of searchling?
I can't because I can't do applescript (if it were PHP...)



[ Reply to This | # ]
An AppleScript to quickly launch applications
Authored by: bobw on Feb 23, '04 01:36:57PM

Why not just drag the Application folder to the Dock, and just right click or Control click to go to the application you want to open?



[ Reply to This | # ]
An AppleScript to quickly launch applications
Authored by: BMarsh on Feb 23, '04 02:30:42PM

we do this for most of the people we support with Mac OS X... some still prefer other methods, but many find this very convenient.

That and their home user folder, then their documents folder all down in the dock.



[ Reply to This | # ]
An AppleScript to quickly launch applications
Authored by: brettmac on Feb 23, '04 01:47:44PM

Is this quicker or easier than opening your applications folder (which is two clicks away)? Really? I know it's cool to write scripts, but this seems fairly labor intensive when two clicks will get you to the applications folder...



[ Reply to This | # ]
An AppleScript to quickly launch applications
Authored by: lstewart on Feb 23, '04 02:36:48PM

The problem with the Applications folder is that some of us like to wear many hats. I am a professional software developer and graphic designer, and an amateur video editor, sound editor, music arranger, genealogist, web developer, etc.

The wide array of applications that goes along with all those hats, means my Applications folder has many, many applications in it, organized into a broad topical heirarchy. Going there every time I want to launch some particular application that's not on my dock is a minor pain I'd like to avoid. Also, putting an alias to the Applications folder on the dock doesn't work so well, because my Mac (dual G4 450) really lags every time I right-click on the icon, because it has to go through and make sure all the icons are up-to-date for the pop-up menu.

I appreciate this hint's approach to solving the problem. I may try it. My own approach in the past has been: make a "Shortcuts" folder in my home directory, and make aliases to all my semi-frequently used apps in that folder. Then I put that folder on the dock. It looks just like I've put the Applications folder in the dock, but it pops up without any delay--I presume maybe because the icons are somehow stored as resources in the aliases, so the Dock doesn't have to look through the app bundles to get each icon. But this still requires manually keeping these aliases up-to-date... thus I rather like the idea of just typing the app's name.



[ Reply to This | # ]
An AppleScript to quickly launch applications
Authored by: RickoKid on Feb 23, '04 10:49:35PM

Bingo! That's why I wrote this script - because it's much faster than right-clicking the Applications folder for me ... I tried moving the applications into task specific categories - but that almost certainly break apple apps when you try to upgrade them. It's just not worth it. Plus I'm used to being able to type in the application to launch it in linux (and even in the dark days when I still used Windows via the shortcut WindowsKey-R).



[ Reply to This | # ]
An AppleScript to quickly launch applications
Authored by: osxpounder on Feb 25, '04 01:22:42PM

Yes, it is quicker. Many of who use our Macs in production environments, or use so many applications that the notion of using the Applications folder directly as our menu becomes laughably unsuitable. In fact, the tendency of Apple to insist on placing certain apps in the Applications folder is, itself, wholly unsuitable for my needs.

My workaround until now has been to create a folder merely for shortcuts [aliases], called "Application Menu", and put THAT on the dock. I can organize my apps into submenus without screwing up Apple's expectation that iMovie or iDVD will be in Apple's chosen folder.

But I do all that because I didn't have the talent or time to write this proposed AppleScript solution. Now that the author has kindly shared the script, I must consider it.

---
--
osxpounder



[ Reply to This | # ]
An AppleScript to quickly launch applications
Authored by: vtrhps on Feb 25, '04 04:23:26PM

I just click on the small piece of the desktop on the side of the Dock to activate the Finder, then press COMMAND-SHIFT-A to open the Apps folder.



[ Reply to This | # ]
An AppleScript to quickly launch applications
Authored by: bonkydooky on Feb 23, '04 02:19:01PM

I just put an alias to the Applications folder on the dock. (and my Utilities and OS 9 Applications). CTRL-click brings up a list of everything in the folder, and away I go!



[ Reply to This | # ]
An AppleScript to quickly launch applications
Authored by: shimrod on Feb 23, '04 02:20:57PM

This is a very cool hint. I've been poking around for a hint like this for a while now. The reason this rocks is people who don't necessarily want to hunt for an app using the mouse..l.ike when I am typing a document and don't want to have to shift through the GUI using the mouse..because it blocks my flow. This way, I just do command shift r, hit return, type the name of the app, and i'm on my way. Sometime the GUI gets in the way when you just Know What You Want...this hint solves that problem very nicely.



[ Reply to This | # ]
Harumph!
Authored by: porkchop_d_clown on Feb 23, '04 04:00:11PM

Not only is this what Terminal was invented for (I keep a little 20x4 terminal window up all the time) our gracious host once published a script I wrote for automatically mapping all applications to aliases:

http://www.macosxhints.com/article.php?story=20020403091601117

One caveat, however - Panther's default csh scripts no longer load the contents of ~/Library/init/tcsh, you have to restore the old scripts by copying them from /usr/share/tcsh/examples into /etc.

---
Everyone loves a clown, but no one will lend him money!

[ Reply to This | # ]

Harumph!
Authored by: sjk on Feb 23, '04 10:49:34PM

Or "source" the example init files. My ~/.cshrc file contains:

if (-r /usr/share/tcsh/examples/rc) source /usr/share/tcsh/examples/rc

See /usr/share/tcsh/examples/README for more info.



[ Reply to This | # ]
Harumph!
Authored by: RickoKid on Feb 23, '04 10:57:26PM

That would work - but this way Applescript finds the application - you don't have to map aliases of type in full path names - Applescript will find the application (even if it is only on a removable disk or network volume I believe)



[ Reply to This | # ]
Harumph!
Authored by: porkchop_d_clown on Feb 23, '04 11:48:53PM

I don't think you realize what the scripts I mention do - they find all the apps automatically and build the aliases, automatically. You don't even have to add them to the script - any file ending in ".app" is found and an alias is built for it. My current alias files include 141 applications, from "addressbook" to "zinioreader". I didn't type in one of them.

---
Everyone loves a clown, but no one will lend him money!



[ Reply to This | # ]
Harumph!
Authored by: TomP on Feb 24, '04 02:05:53PM

I think it's clear that launching MacOSX apps is /not/ what the Terminal was invented for, or you wouldn't have to resort to massive alias creation in order to make it usable for that purpose. This script is a much cleaner way of quickly making all your applications accessible than anything that requires bringing up the Terminal.



[ Reply to This | # ]
Harumph!
Authored by: porkchop_d_clown on Feb 26, '04 03:29:34PM

How is making aliases a "resort"? It's what they're for. Add in autocompletion and I can launch any app by just typing the first few letters.

I think you're reaching for reasons to hate terminal.

---
Everyone loves a clown, but no one will lend him money!



[ Reply to This | # ]
An AppleScript to quickly launch applications
Authored by: brw3sbc on Feb 23, '04 04:04:11PM

I must say that I am often mystified by hints that seem to take the long way to do something. This is one such hint. It leaves me wondering if I am missing some finer point.

As another reply has stated, an Alias of the Applications folder in the Dock will cause, upon a single mouse click down, the presentation of the Applications folder in a hierarchical manner. Simply sliding the pointer through the folders to the application, then releasing the mouse button, launches the application (or attempts to open the file if it is not application). A single click, one-handed operation. I keep my Dock hidden on the left of my screen, where is springs to life when the pointer touches the edge. It's as close as I have been able to come to the old Apple menu without using third-party solutions.

If, indeed, I have missed the value of this hint, and how it improves upon my solution, I welcome an explanation. Regardless, hats off to the author's Applescript skills and OS knowledge.



[ Reply to This | # ]
An AppleScript to quickly launch applications
Authored by: edoriv on Feb 24, '04 09:47:06AM

as another has already pointed out...

Some of us have many many applications in our Applications folder... And even though we can organize the ones we install into sub folders apple insists that we not move the ones it installs or else software update breaks.
this makes for a sloppy menu and sloppy organization. Also apple doesn't allow you to sort folders to the top or bottom so apps and folders are a mixed up mess... couple this mixed up mess with many many applications and it is far slower to navigate a menu to launch an app. that simple right click on a dock item would take too long to load the menu in my case... and then rolling up and down the menu, maybe missing the target and having to reopen the menu ( it happens ) just not convenient.

I will give credit to this applescript solution and it's great for a free solution but it is far from Launchbar...

I use Launchbar and it is a true time saver... I simply type command space and then PS and Photoshop launches or FW and Fireworks launches, or DW for Dreamweaver, Ter for Terminal, Tex for Textedit and so on... Launchbar learns the shortcut you want to use for each item as you use them.

it will also open bookmarks and contacts ;-) everything is a command space away... hold the command key while opening an item and it will reveal in the finder .... I only mention launchbar because it really does save time because I don't even have to spell out the entire app name and no extra step of choosing other I simply type and the list of possible matches shrinks most times to only one...

This applescript is great if you don't want to pay or don't want all the extra features but if you have a hard time seeing why this can help speed things up read about launchbar maybe that will help you understand how it can speed workflow.



[ Reply to This | # ]
An AppleScript to quickly launch applications
Authored by: TomP on Feb 24, '04 02:16:17PM

Anyone who's satisfied with opening the Applications folder to launch applications, can't possibly have very many applications installed. If your needs are simple, then this script probably won't do much for you. I'm not sure how many Panther ships with, but I now have 97 apps under my Appiications directory (organized into folders to keep things manageable), plus a couple dozen more under /Development/Applications. I have my 15 most used apps on the Dock, but getting to the others is aways a bit awkward. I've been wanting something like this script for some time and I'm very happy someone finally sat down and cranked it out.



[ Reply to This | # ]
An AppleScript to quickly launch applications
Authored by: bq on Feb 23, '04 04:42:50PM
Okay, I know the author of the hint gave a tip of the hat to Launchbar. Still it's worth mentioning that Launchbar does a very, very, very good job of this for a minimal price. I'd suggest that anyone who thinks of using this hint try out the trial version of Launchbar first, and then decide which route to follow.

[ Reply to This | # ]
An AppleScript to quickly launch applications
Authored by: DavidRavenMoon on Feb 24, '04 08:46:33AM

Indeed... I love LaunchBar. That and DragThing, and I'm covered! Still this is a very cool hint, and it's wonderful to see OS X users sharing their talent for the betterment of others! :)
.



[ Reply to This | # ]
An AppleScript to quickly launch applications
Authored by: tb51 on Feb 23, '04 05:27:02PM

Well, it's exceedingly clever - I admire your Applescript knowledge, but you really should try LaunchBar. I tried it, I bought it, I couldn't live without it. It truly is more intuitive than a WIMP GUI - well it works the way MY brain works, anyway… and I never have to remember where I left anything anymore!

---
TB



[ Reply to This | # ]
An AppleScript to quickly launch applications
Authored by: ZZamboni on Feb 23, '04 05:45:51PM
Hi,

Apart from the other mentions of LaunchBar, I would like to mention Butler. I bought LaunchBar and love it, but I find myself using Butler now. It does the same, plus a few other things (including a search engine interface, disk-browsing menus, etc.). Very nice.

[ Reply to This | # ]

An AppleScript to quickly launch applications
Authored by: dave1212 on Feb 24, '04 03:47:07AM
Hear, hear! I'll second that, the former "Another Launcher", a Pick of the Week, is a true blessing. The author listens to feedback, etc. and it shows. Happy to donate.

Butler is indispensable. I just wish the "search macosx hints forums" script worked, it doesn't seem to any more.

---
______
http://www.68kmla.ca/

[ Reply to This | # ]

An AppleScript to quickly launch applications
Authored by: jeremyrh on Feb 24, '04 05:52:43AM

And don't forget Tiger Launch from Ranchero Software - a small paw-print in your menu bar that unfurls into a customisable menu of applications. Simple. Works.



[ Reply to This | # ]
Slight changes I made to my copy...
Authored by: donaciano on Feb 23, '04 08:02:04PM

Great hint! Love it. :)

To speed it up a lil more I wanted "Other..." at the top near the most recently used item so I wouldn't have to work my way up the list with the arrow when I want a recent item.

Change 2 lines to do this :

From :
set runList to (text items of runListString & ("Other ..." as list))
To :
set runList to (("Other ..." as list) & text items of runListString)

That way you get "Other..." at the top instead of the bottom of the list.

Then to have "Other..." selected at the top change
From :
"Choose Application to activate" default items (last item of runList) ¬
To :
"Choose Application to activate" default items (first item of runList) ¬

Not a big deal I know, but it makes it nicer for me. (Great way to learn AppleScript too, take something you like and change it a lil)

-don.



[ Reply to This | # ]
An AppleScript to quickly launch applications
Authored by: BulbVivid on Feb 23, '04 08:23:46PM

Though this strays from the original post--a nice script--while on the topic of app launchers I thought I'd throw in a word for pearCalc, which I found after it was mentioned in a previous post in this forum.

PearCalc is a no-frills app launcher, and it's free. It automatically adds typed applications to a list and then autofills in a minimal window. Though somewhat limited in options--not that that's bad--this app's changed the way I use my computer. I rarely open the applications folder, and my dock is empty of all but running apps.

I tried most of the others, but they all seemed a little overblown to me. Between pearCalc and iKey I can get to things quickly and do things I didn't think were so easily possible.

And pearCalc's really supposed to be a calculator, though I have yet to really use it for that.

Check it out, it may work for you:
http://www.versiontracker.com/dyn/moreinfo/macosx/13724



[ Reply to This | # ]
An AppleScript to quickly launch applications
Authored by: MN OSX HAM on Feb 23, '04 08:30:39PM

I like this!
Don't want to use LaunchBar.

Thanks for sharing.



[ Reply to This | # ]
An AppleScript to quickly launch applications
Authored by: staggie on Feb 23, '04 10:06:50PM

I tried it, but don't see any advantage over just placing the applications folder on the doc. One right-click and it opens immediately; I've grouped my apps in folders so the list is pretty short.



[ Reply to This | # ]
YADAL
Authored by: Han Solo on Feb 23, '04 11:13:21PM
For something a bit more customizable than plopping one's Applications folder in the Dock, consider Yadal: Yet Another Dock Application Launcher. Take a few minutes to set it up and then be amazed at its small footprint, flexibility (for what it does, nothing more) and ease of use. And it's free too.

(No, I'm just a satisfied "customer.")

[ Reply to This | # ]

An AppleScript to quickly launch applications
Authored by: rotaiv on Feb 24, '04 11:06:03AM

I agree with may of the posts where people have commented on the size, organization and/or limitation of the default Applications folder. What I did was create a new folder called "Apps" and created aliases for my commonly used Applications in that folder. It is the "Apps" folder that is on my Dock and not the full blown "Applications" folder.

This allows you to arrange, include/exclude any application you want. Just in case, I have an alias for " Applications" and " Utilities" in the "Apps" folder. Note the space before the file name. This puts these aliases at the top of my list so that I don't have to scroll over them to get to the other application aliases.

Now I just click and hold the "Apps" alias in my dock, select the application I want and I'm all set. Doing it this way, I really don't care how much is in my Applications directory because I rarely go there. A small directory with nothing but aliases loads really fast and I can put them in any directory organization that suites my needs.



[ Reply to This | # ]
An AppleScript to quickly launch applications
Authored by: dogboy on Feb 24, '04 12:39:09PM

Or you could put the aliases in your user applications folder, to keep things tidy.



[ Reply to This | # ]
Have you tried Terminal.app?
Authored by: nyarlathotep on Mar 02, '04 02:02:12AM

This is NOT how things are done in modern shells.

Step 1. Type "fink install bash-completion"
Step 2. Open a new terminal window, type scp .bash_history blah:<tab><tab> where blah is a system you have passwordless ssh authentication to (say via an ssh-agent).

Notice anything? Yes, thats right, it frigging sshed to blah and found all those frigging completions for you!!!!!

Now the one correct way to do this is to add application name completions to bash, by adding a file called /sw/etc/bash_completion.d/Applications

This file will look something like:

alias app='open -a'
_app() {
...
}
complete -F _app $nospace app

where the internals of the _app function resemble the _scp function from the file /sw/etc/bash_completion, but instead of using ssh to fetch the info with ls, it fetches the info with one of the miriade other shell scripts posted inside this hint. I do not feel like writing it now, but it should be very easy.



[ Reply to This | # ]
AppScript Launcher 1.0
Authored by: RickoKid on Oct 25, '07 05:37:37PM
This is probably old news now, but I've put together an updated and improved version of this script, it's now available on my blog.

=> Tumbleseed


[ Reply to This | # ]