[Feature Request] Suggested Change to the Focussed Window Trigger


Currently, in my experimentation, a macro set to trigger using this setting above does, indeed, get triggered when a different window is selected inside an application, or when the application itself loses or reacquires focus. This makes sense.

However, when the application has one remaining open window, which I then close, the macro will not be triggered. My guess is the trigger actually responds to a different window acquiring focus, but does not respond to a window losing focus.

@peternlewis, would this be something you think might be reasonable and achievable to implement at some future point ?

My motivation for investigating this was to create a macro that would quit applications once the last open window is closed if they remain otherwise normally remain open (TextEdit, Preview, QuickTime Player, etc.).

Within the relevant application's macro group (e.g. TextEdit), you could use command-w as a trigger for a macro that closes the front window (i.e. command-w works as usual) then checks for an enabled menu item in the Window menu (i.e., another open window). If one is found, the macro simply ends; if none is found (i.e., if you have just closed the last open window), the macro quits the application.

That is a good idea, @thoffman666, and in fact one I’ve already implemented. It works well, however I was also hoping to create a macro that would do a similar thing when I closed a window using the mouse.

Well, I suppose you could do the same thing with a mouse click trigger: first allow the mouse to click, then check for open windows, and quit if there are none. The macro wouldn't have to distinguish between a click for window-closure and any other click, because any other click would still leave a window open, rendering the conditional false.