Open folder trigger?

Is there a trigger that runs when a specified folder is opened? I would like to run a macro when the Documents folder is opened while holding down Command.

Thanks

I presume you've looked at:

Folder Trigger

The Folder trigger (v7.0+) executes the macro when a specified folder on your Mac:

  • adds an item.
  • removes an item.
  • adds or removes an item.

The item must be directly in the folder - changes in a subfolder will not be noticed.

That's not what you want, I think, because you talked about running a macro simply by opening the folder, but using a modifier key when you open it.

KBM has another trigger that monitors the title of the frontmost window as you change from app to app and tab to tab. I don't think that's what you want either. I also think you don't want it to be watching everything and catching when something happens, you want to deliberately say, "Do this now" and you want it to be simple keystrokes. Am I right?

Could you clarify what you want to do? Do you want to be holding the Cmd key when you click on the name "Documents" in the Finder Sidebar? Is there something special about exactly that way of triggering it? Does it need to be instantly when the folder window changes? Do you want this to happen every time you open Documents, or just when you "say so", like by holding down the Command key? Would it be OK if it was a hotkey that only worked when the Documents folder was already open, so you would open Documents and then press ⌘X, for instance? Or is two steps too much for the way you envision interacting with it?

Why not assign a trigger such as ⌃⌥⌘O to the action: open file, in your case the documents folder, and then include whatever macro you want to run? It will always work if you make it global, even if you happen to be in the documents folder

Opened how? In what?

If you mean by double-clicking in Finder, remember that by default the Command key is a modifier that causes the item to open in a new window or tab. So you might be able to do something with the "Focused window changes" trigger, checking the %WindowName%1% token and only continuing is it is "Documents".

But I'd tend to @Mistjah's solution -- use an hotkey trigger to execute a macro that opened "Documents" in a new window and then did whatever.

I only used the Documents while holding Command as an example. I thought there should be an open folder trigger so that it triggers any way the folder is opened, such as when I double click a particular folder, when I open it with one click via the Finder sidebar, or even select the folder and press Command-O.

And then I thought there should be options to add modifiers, such as command or control.

So really if this is not possible, then I guess this is more of a feature request.

Thanks.

That's doable.

How about: "Run this macro every time a Finder window opens this folder, whether it's a new Finder window or if the Finder window changes to this folder"?

  1. Make a group that is enabled and only available for Finder.
  2. Make a macro in the group with a trigger of "Focussed Window Title Changes" and specify the folder name as the title. See this trigger type in the manual for details of the options.
  3. Put whatever you want in the macro.

If you need more detail, please ask.

There is no macOS or Finder "a folder has been opened" Event (at least, not available via public API), so there's nothing KM can use as a trigger.

The closest you'll get is by inference, using the window title change method already mentioned, but that can be prone to false positives if you aren't careful.

You may have to limit the methods you are using to open folders -- you could, for example, have a macro that you triggered by hot key and opened the currently-selected folder and did whatever you want.