How can I stop a macro from firing when switching away from my password manager with ⌘Tab?

I’m using a password manager app, and I have a Keyboard Maestro macro that automatically clicks on the search field whenever the password app is activated. This is convenient because I don’t have to press ⌘F or manually click the search box when the app sometimes doesn’t focus the search field by itself.


However, this macro also runs when I switch from the password app to another application using ⌘Tab. In that case, I don’t want the macro to fire. I know I could hide the password app to avoid this, but if possible I’d like the macro to run only when the password app becomes active in the foreground, and not when I’m leaving it via ⌘Tab.

Is there a way to set up the macro so that it doesn’t trigger when switching away from the password app with ⌘Tab? If so, I’d appreciate any suggestions or example macros.

I'm a bit confused by this as the current application should not "activate" if you switch away from it using the Application Switcher.

It doesn't in my testing.

Thanks for your reply. After tweaking some settings, the strange behavior seems to have stopped for now—for example, I added a short pause to the macro. I’ll keep an eye on it for a while and see how it goes.

1 Like