Opens a Second Finder Window if One Is Already Open

Opens a second finder window if one is already openMacro (v10.2)

Open Finder.kmmacros (4.6 KB)

No, it really really doesn't do that. All it does is open a new Finder window.

Working through the logic:

  1. The variable WindowCount is set to 0
  2. The first "If..." action does absolutely nothing since it contains no actions in either the "execute" or the "otherwise" branches
  3. The second "If..." action does nothing, for the same reason
  4. You use an AppleScript to open a new Finder window

More subtly -- you only need the AppleScript if the Finder is not the frontmost application when you run the macro. And using an AppleScript action is an unnecessary "expense" when you can command an app "directly". Since you most likely want to be in the Finder after you've created a new window (and assuming you need a macro rather than just using ⌘N either via the keyboard or a Stream Deck button):

If you're going to use AppleScript anyway then make full use of it...

tell application "Finder"
   if not (exists of window 1) then
      make new Finder window
   else
      # Whatever...
      beep
   end if
end tell

Now THAT was / is an elegant solution. That is exactly what I wanted to do. I think I have narrowed down my personal issue with this.

I need to put effort into understanding the actions panel and, like you say, get to the root of what I actually want to do and why. THEN start looking for a solution.

At the moment, I am just using KM with Stream Deck for one push button functions to open apps. (so pretty basic) Now you have educated me by showing how I can automate the selection of menu items, I am thinking of other things to do.

(BIG THANKS FOR THAT)

1 Like