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

Launch items in Stacks via AppleScript and keyboard System
Unfortunately, my two favorite application launchers -- Butler and Quicksilver -- aren't quite up to snuff with Snow Leopard just yet. Spotlight works OK most of the time, but I've started to rely on the Dock's stacks for launching what I need. However, I'm very keyboard-centric, and I don't like going to my mouse any more than I have to, so I wrote an AppleScript that will open the Stack for me, and using 10.6's new Services features, I can trigger that AppleScript with a keyboard shortcut. Here is the script:
tell application "System Events"
  key code 99 using control down -- ctl-F3 to focus on Dock
  keystroke "Applications" -- should take focus to Applications folder
  key code 36 -- hit Return to open stack
end tell
Once the Stack opens, you can type in the first few letters of an application and hit return to launch it. The script itself is fully compatible with 10.5 as well, but assigning it to a keyboard shortcut natively is not. The following bit is 10.6 only.

Now open Automator and make a new Service. Select no input from the 'Services receives' drop-down menu. Drag in the Run AppleScript action, paste in the above code, and save. You can assign your new Service a keyboard shortcut under System Preferences » Keyboard » Keyboard Shortcuts » Services; it should be listed under the General section.

There are a couple of drawbacks to this method. First, it's not quite as fast as I would like (Automator seems to slow things down for some reason), and also, you have to be sure to release the keyboard after you enter the shortcut, or the keys you are holding down will affect the script. Fairly obviously, it doesn't replace most of the functionality that Butler and Quicksilver have, just a small portion of it.

You can use this for any stack in the Dock. Just keep in mind that the Stack has to have a unique name, since AppleScript is typing the name of the folder to access it. So if you had a Stack called Mail, the script would open the Mail application (if you have it in the Dock) instead. Hope this helps some people while we wait for our favorite launchers to catch up to 10.6
    •    
  • Currently 1.78 / 5
  You rated: 4 / 5 (9 votes cast)
 
[6,036 views]  

Launch items in Stacks via AppleScript and keyboard | 9 comments | Create New Account
Click here to return to the 'Launch items in Stacks via AppleScript and keyboard' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Google Quick Search Box?
Authored by: Andrew J Freyer on Oct 14, '09 08:05:32AM

As a keyboard application/file launcher, I use Google Quick Search box (and have for quite some time) without any hiccups in Snow Leopard. You might try that in lieu of Quicksilver, although GQSB does not have the additional features (scripting, file control...) that QS does.



[ Reply to This | # ]
Launch items in Stacks via AppleScript and keyboard
Authored by: ccjensen on Oct 14, '09 08:33:51AM
this doesn't seem to work for me. The first action (ctrl+f3) works fine, and the dock gets selected, but the Applications stack is never selected. I tried modified the "keystroke" command to just an A, and I tried Docu, but it's as if the dock never recieves the instructions. I also tried changing it from keystroke to keycode 0 (which is an A), but still nothing. It works fine if I manually do the keypresses.
This made me check the console, and I keep getting this message when running the script:
14/10/2009 16:32:01 /System/Library/CoreServices/System Events.app/Contents/MacOS/System Events[99582] CGSKeyTranslateInitialize: KLGetCurrentKeyboardLayout or KLGetKeyboardLayoutProperty is not available, fall back to USA keymap
Any ideas?

[ Reply to This | # ]
Launch items in Stacks via AppleScript and keyboard
Authored by: V.K. on Oct 14, '09 09:46:17AM

A nice hint but what exactly is the problem with Butler? I use it all the time. So far I haven't encountered any issues with it in Snow leopard.



[ Reply to This | # ]
Launch items in Stacks via AppleScript and keyboard
Authored by: elspub on Oct 14, '09 01:56:32PM
Quicksilver works great in Snow Leopard. The original developer has left the project, but its now open source and its current beta is as stable and snappy as I've experienced QS to be. A few plugins don't work on Snow Leopard, but its still more robust than any other options...
http://code.google.com/p/blacktree-alchemy/downloads/list

You can even use it to trigger applescripts like the one in this comment. QS seems to run applescripts faster than the services menu.

[ Reply to This | # ]
Launch items in Stacks via AppleScript and keyboard
Authored by: Stormchild on Oct 14, '09 07:20:16PM

LaunchBar, baby. Still the best.



[ Reply to This | # ]
Launch items in Stacks via AppleScript and keyboard
Authored by: Helge33 on Oct 15, '09 04:50:50AM

I found it amazing (and amusing) how people make an effort to find yet another launch method and eventually save 1-2 key buttons ;-) Since 10.5 I totally gave up on all these external launchers and utilities. It never takes me more than 3-4 keystrokes to launch an app with *Spotlight* and its faster than anything else. And more important: I dont have to waste time to check for "compatible" tools when I just want to update my OS.



[ Reply to This | # ]
Launch items in Stacks via AppleScript and keyboard
Authored by: DarthMagnus on Oct 15, '09 08:48:13AM

The problem with Spotlight isn't the number of keystrokes, it's usually the number, and variety, of results. Most of the time, for launching applications or specific tasks, Spotlight just yields too much stuff, and it takes more effort to manually select the specific result that you want. Also, the more you put on the computer, the slower Spotlight gets. The advantage of Butler, Quicksilver, Launchbar, etc. is that you get to select a specific subset of results to view, and you can still take full advantage of Spotlight and all of its results.



[ Reply to This | # ]
Launch items in Stacks via AppleScript and keyboard
Authored by: Helge33 on Oct 15, '09 09:43:25AM

I would have totally agree to this with Tiger, where I was a big fan of Quicksilver. But as now with 10.5 Spotlight remembers the most selected search results when typing "sa" I immediately get "Safari" as top choice. And in the upper right SL window "Applications" are always shown first.

However scripts like yours can easily be extended to do more complex tasks than app startups. And of course there is no such thing like the "best" approach for all users for working with the OSX GUI ...;-)



[ Reply to This | # ]
Launch items in Stacks via AppleScript and keyboard
Authored by: dcottle on Nov 12, '10 10:56:00AM

I set a shortcut key to "focus on dock", then navigate via key strokes.



[ Reply to This | # ]