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?
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
tell application "Finder"
if not (exists Finder window 1) or (get collapsed of the front Finder window) then
make new Finder window
tell application "Finder"
set the target of the front Finder window to (POSIX file FinderPath)
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.
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?