Go to Folder macros don't work since macOS update from 10.14.6 to 12.5.1

So I finally bit the bullet and updated my OS to a current version. Mojave really was a golden build for me in that I loved the desktop environment, it was highly compatible with legacy drivers and software and bloat was minimal. But it was time to move on, as professional apps I rely on were starting to drop support. I expect to have to re-jig some macros and that's fine.

One very basic one that's giving me issues is a set of keyboard commands I use to navigate the focused Finder window to specific directories. I've been pasting a named clipboard into the Finder Go to Folder... prompt and simulating a Return keystroke and this has worked for me for many years. I prefer it over the Open a File, Folder or Application action because that opens a new finder window when I would rather keep my screen space tidy.

Now in Monterey, the macro calls Go to Folder... successfully but fails to paste into the dialog. The clipboard is loaded and I can paste manually without issue. I can use the Pause action to correct for this but would prefer to keep things as speedy as possible. I've disabled UI animations in System Preferences but the macro still won't trigger without introduction a pause.

I guess my question is whether I can execute the Open Folder,[...] action without opening a new window, or if not, how can I best optimize my existing macro for speed?

Thanks as always for your patient guidance.

Try adding a 0.3s pause before the paste, to give the Go to Folder... window time to appear.

Here's a neater alternative:

Go to Path in Current Finder Window.kmactions (2.1 KB)

Screenshot

Thanks for the Applescript, I should have considered that. I'll give it a try.

So this works great. Even more efficient than what I've been used to so I'm glad to have had my hand forced a bit.

One hitch was that if no Finder window is present or focused then in that case I would like a new one created. I've got it now so that it checks whether there are no Finder windows and creates a new one if not:

set inst to system attribute "KMINSTANCE"
tell application "Keyboard Maestro Engine"
	set FinderPath to getvariable "Finder_Path" instance inst
end tell

tell application "Finder"
    if not (exists Finder window 1) or (get collapsed of the front Finder window) then
        make new Finder window
    end if
end tell

tell application "Finder"
	set the target of the front Finder window to (POSIX file FinderPath)
end tell

The only thing remaining is that if there are Finder windows open but none are in focus then the script does nothing. Can anyone make a suggestion for how to handle that case? If no Finder window is in focus then I still want to create a new window and direct it to the Finder_Path variable.

This should do it. You don't need the extra bit of AS.

Go to Path in Current (or New) Finder Window.kmactions (3.4 KB)

Screenshot

Is the 'Expand Tilde In Path' action for the benefit of the AppleScript?

Yeah.

Thanks again for this. I'm curious, what's the different between %FrontWindowName% (as you entered it here) and %WindowName%1%, which is what KM enters in to the field when you select from the drop-down list of all tokens?

They're interchangeable.

https://wiki.keyboardmaestro.com/token/Window_Tokens

1 Like