Trigger a Macro when a particular file is opened?

Is it possible to trigger a macro when a (particular) file opens?

Not directly, no. You would have to detect the consequences of opening the file (eg application activating, window name, etc).

I see a focused window trigger, but the options I see don’t seem to allow looking for a particular window name. I believe I could set up a trigger to look for a change in the focused window (if I’m understanding the focused window triggers correctly) that would then examine, as a step within the macro, the name of the newly focused window, but wouldn’t that be “overkill” to have a macro triggering that frequently (every single time the focused window changes) in order to test for a particular window name? (Maybe I’m not understanding how the focused window trigger works.)

That is pretty much the only way. It can be restricted to only when the title changes and only within a specific application.

But other than that, I don’t see any way to detect a file being opened.

An alternative is to use a macro to open the file. That way, the macro is already running and can do whatever it needs to once the file is open.

Thanks for your suggestion: I can as easily double click a macro file, as the target file itself.

I agree that that having a trigger to activate when a particular file opens would be a very useful thing!! Can this be added to KM?

Do you mean trigger a macro when you open an arbitrary file with an arbitrary application? No, there would be no way to detect that.

You might be able to detect the consequences (a specific application/window coming to the front), but only in particular cases.