0

I would like to hit cmd+X to switch to (or launch, if it's not running) the #X application in the Dock, without hardconding that application.

I.e. if my third application in the dock is the Terminal, I hit cmd+3 and I switch to the terminal, but if I then move Adium to that position, cmd+3 automatically opens Adium.

Can this be done on OSX 10.8 (or 10.9)?

Even better, though that's not required, if in case I hit the combination of the already active application, it hides it instead.

o0'.
  • 1,986

2 Answers2

3

You could save one AppleScript for clicking each Dock icon:

for i in {1..9};do echo 'tell application "System Events" to tell process "Dock" to click UI element '$i' of list 1'>~/Library/Scripts/Focus\ Application\ $i.applescript;done

Then use FastScripts to assign shortcuts to the scripts.

I find it easier to just assign keyboard shortcuts for applications though.

Lri
  • 105,117
  • I'll leave it open for a while, just in case someone comes up with an application which does that. – o0'. Nov 03 '13 at 14:40
1

With AppleScript you can do something like that :

tell application "System Events"
    click item # of UI elements of list 1 of process "Dock"
end tell

But the actual problem is binding it to the shortcuts.

Edit:As Lauri Ranta reminded me by his anwers, there is FastScripts.

Matthieu Riegler
  • 21,486
  • 11
  • 59
  • 97