Apple Mail: Deactivate BTT when Spotlight Search is active

In my normal workflow, I use Spotlight search to start applications. If any Mail application windows were active before I activate Spotlight search, the keys that are captured by BTT for the Mail application are unavailable in Spotlight. I see older posts where this is addressed but I don't see these options in rules for things like "visible_window_list" nor do I see the button mentioned that allows me to see that list. Could someone please steer me in the right direction here?

Thanks

@Andreas_Hegenberg Any thoughts on this?

The problem is, "visible_window_list" is only available for advanced trigger conditions but not for conditional activation groups. This is because monitoring all windows is a relatively complex task that can use some CPU.

Can you describe your exact setup? Maybe there is a workaround

Not sure how detailed you need me to be about "exact setup"...

This is an issue whether running on my Macbook Pro or my Mac Studio.

As mentioned, if I wish to start an application, my typical workflow is to activate Spotlight search with Cmd+Space and then start typing some part of the application name that I wish to start. If any Mail application window, Inbox or Compose window, were active when I activate the Spotlight search input, the keys which I am capturing with BTT in Mail to simulate Gmail key bindings are captured and unavailable to me in the Spotlight input. In order to have all keys available to Spotlight input, I must click a window other than Mail and then go back to typing in the Spotlight input, which kind of defeats the purpose of an all keyboard interface to starting apps.

Let me know if there are other specific details that you need.

BTW, this is the other post I found raising these same issues...

unfortunately I think there is currently no good way to achieve this.
You could add an advanced trigger condition to your shortcuts in Mail, however then you'd need to define them all twice with contradicting conditions.

I'll soon add an option to have conditional activation groups that poll variables, then users will be able to decide theirselves whether they want to spend some CPU for something like this.

Maybe this does not work ... but what if the shortcut that opens the Spotlight window also deactivates BTT and Enter (completing the search) reactivates BTT? Then you wouldn't have to set up the shortcuts twice ... I think :innocent:

problem is there are so many ways to close spotlight (click outside, enter, selecting something ...)

Mm, that's true. You should get into the habit of always ending the search with Enter. However, @RandyT wants to do everything with the keyboard, if I understand correctly. So, clicking is not an option.

That would be a workable solution for me as I am typing a few chars and then hitting enter when I have a match for the app I wish to open. Never taking my hands off the keyboard.

I try to do that too, but I don't succeed. How do you do that? :slightly_smiling_face:

You probably have to set up two Enter shortcuts.

  1. Enter = Enter (if Spotlight window is not visible)
  2. Enter = Enter plus toggle BTT (if Spotlight window is visible)

I think I came up with a good solution that is independent of how you close Spotlight:

spotlight.bttpreset (7.7 KB)

How it works:
• It triggers on cmd+space and forwards that to the system to show spotlight
• It sets customVariable1 to "SpotlightActive"
• It uses the "Wait for Conditions To Become True" action to wait until the Spotlight window has disappaeared again
• It sets customVariable1 to "SpotlightNotActive"

Now you can define a conditional activation group that checks the customVariable1 and assign your Mail Shortcuts to that group (or add the variable check to any existing group)

This sounds like it should work, but it does not quite work yet.

When I press command-space, before typing any chars with spotlight search input still displayed on the screen I see the "spotlight ended" HUD. So after I release the spacebar, it is somehow interpreting that spotlight is done.

did you import the preset I shared? It‘s important to add a small async delay after the shortcut, because the spotlight window takes a few ms to show up

(it seems to work really well here - macOS 14.5)

Yes, I imported the preset you shared.

BTT v4.533 and macOS 14.5

Weird, I'll check whether anything related has changed with the new versions (current alpha is 4.586 )

I am running on workstation with two monitors.. not sure if that could cause the different behavior.. Will give it a try on the laptop shortly.

Latest alpha does not change behavior.

Same behavior on my laptop.. also macOS 14.5