OS X-like folder shortcuts

There is updated version of this macro described below that you can download from here → mcskrzypczak-KM-GoToDropbox_v1.1.

Probably all of you know those OS X shortcuts for quickly switch to default folders:

  • ⇧ ⌘ D – for Desktop folder,
  • ⇧ ⌘ O – for Documents folder,
  • ⌥ ⌘ L – for Downloads folder,
  • etc.

Those can really speed up navgation process. Moreover, they are supported in many apps (in dialog windows for open/save files). Personally I use such shortcuts many time a day. Unfortunatelly, there is no possibility to make own keyboard shortcuts for other folders. Well, but we have Keyboard Maestro, right?

What I want to achieve is to get as close as possible behavior of KM macro to default OS X shortcuts:

  1. When no Finder window is opened the macro would open new on specified folder.
  2. If Finder window is already opened the macro would change its destination to specified folder.
  3. And of course the macro will work in other apps – in dialog windows.

So here is example macro that would open Dropbox folder (usually placed in ~/Dropbox):

It is easy to modify (just change value of first var – MyFolder to folder that is within user's home folder), uses AppleScript when Finder is focused and it really fast then. In other cases it uses some Keyboard Maestro magic and is not as fast as default shortcuts, but still faster than manual folder changing.

Maybe you will know some better methods to make it faster?

You can download my macro from here → mcskrzypczak-KM-GoToDropbox_v1.0. It should be placed in Macro Group that works everywhere (like default Global Macro Group).

Hello Maciej,

Let's see...

Keyboard Maestro understands home-folder-notation:

~/ == your home directory.

Go-To sheets on OSX also understand this notation.

So you don't need to shell-out to get the home folder.

KM also has a filter to convert home-notation to a full path when needed.

AppleScript can talk to Keyboard Maestro directly:

tell application "Keyboard Maestro Engine"
  set myVar to value of variable "myKMVar"
end tell

NOTE: the Keyboard Maestro variable name is quoted.

Any time you shell-out from AppleScript there's a speed hit (although this is much less than it used to be), so don't use the shell unless there's real value in doing so.

While there's nothing really wrong with your script, I'd probably write it more like this:

tell application "Keyboard Maestro Engine"
  set myTargetFolder to value of variable "var"
end tell

--> "~/Desktop/Excel Scripting/"

if myTargetFolder starts with "~/" and myTargetFolder ≠ "~/" then
  set myTargetFolder to (POSIX path of (path to home folder)) & text 3 thru -1 of myTargetFolder
end if

set myTargetFolder to alias POSIX file myTargetFolder

tell application "Finder"
  if front window exists then
    tell front window
      if (get its target as alias) ≠ myTargetFolder then
        set its target to myTargetFolder
      end if
    end tell
    set newWin to make new Finder window
    tell newWin
      set its target to myTargetFolder
      # Change size & position of window — just for example.
      set bounds to {0, 45, 844, 1196}
    end tell
  end if
end tell

I'd try to do without pauses (unless necessary) and depend more upon detection of actual elements.

So. You can definitely get some more speed out of if.

I use Default Folder for this sort of open/save dialog manipulation which is a bit faster still.

Best Regards,

Thank you @ccstone for your suggestions!

As of avoiding pauses. I choose to use them because of versatility of macro. The method when KM recognizes buttons is of course faster but it depends on system language. This leads to some problems. If someone uses non-English version of OS X some apps will be translated and use translated version of word “Go”. But there are some apps that are English-only, so they would have “Go” button. You end with two versions of “Go” button: translated and non-translated.

Ah. Localization issues can be problematic.

I don't work with non-English systems, so there are issues I'm unfamiliar with.

I would still probably still use a Pause-Until Any action and just add the localized button names.

Or come to think of it you could use a regular expression.

(?i) means case-insensitive.

If I used a regex I'd probably write it a little tighter to avoid false positives.


Hear I'm bracketing the possible names with beginning (^) and end ($) of string.

So. If you really need to be generic to the max the pause method will certainly work, but keep in mind that there are alternatives.


1 Like

Well, I knew creating account here was a good idea. :wink: I did not know that I can use some sort of regular expression in Pause Until button is enabled element. Now I know!

So here is my updated version of that macro:

Thanks to @ccstone suggestions it works even faster, is more reliable and works with non-English versions of OS X. In last case you have to edit two actions: Pause Until All Conditions Met and Press Button… – just change word Idź to the version used in your language (check the button in Go To in Finder).

You can download updated version here → mcskrzypczak-KM-GoToDropbox_V1.1.