Any ideas why this Macro isn't triggering / functioning as intended?
A bit of background:
Microsoft Teams has (what I will call is) a bug where, after awhile, a hidden window will appear with the title Microsoft Teams Notification. This isn't really the bug, but because this window exists, if I ⌘Tab on my Mac to go from one app over to Teams and I'm not on a Desktop where the main Microsoft Teams window is present, the OS will "switch" to Teams but the front-most window will be this hidden notification window. The anticipated behavior when I activate/switch to an app using ⌘Tab on my machine (an environment that uses multiple monitors and desktops) is to have the OS switch to a desktop where that application has a window present. This is the behavior for every other app on my computer. This isn't really happening with Teams because the OS is activating Teams with the front window being this hidden notification window whenever it exists.
Hopefully I've painted a clear enough picture of the problem for which I'm trying to solve. As for a solution, I'm trying to create a Keyboard Maestro macro that will change the front-most window of Teams to the main window whenever I ⌘Tab to Teams and this dumb hidden "Microsoft Teams Notification" window is present (i.e., restoring the anticipated function of ⌘Tab on my Mac). One additional fact to note is that the name of the main Teams window (the one that should be brought to the front when Teams is activated) is not consistent — it changes depending on where I was when last the app was active. So, simply using Keyboard Maestro to select the desired window from the app's dropdown menu is not an option. Not also that I want to avoid using any move and/or click mouse type actions given the fickle nature of that solution.
The intended solution:
All that said, I think I have a fairly straightforward and simple way of fixing this behavior with Keyboard Maestro but I can't seem to get this macro to fire and it's driving me nuts.
Essentially what I'm trying to do is have Keyboard Maestro type ⌃Down Arrow followed by another Down Arrow and then Enter whenever that pesky window shows up in Teams. I can do this myself manually and it works like a charm. (It's the universal OS keyboard shortcut for toggling through the various windows of the active application.) But doing it manually is a drag and throws off my groove. (Keyboard Maestro to the rescue.)
You'll note in the screenshot below that the condition of my If Then Else statement appears as "(currently false)" but with evaluating condition results turned on, I can see that the If statement does show as "true" when I ⌘Tab from Keyboard Maestro over to Microsoft Teams and that hidden window is present. Any ideas what's going on or how to troubleshoot why this macro isn't working as intended?
I should note that:
I've also tried adding a short pause between the keystrokes but that didn't solve anything.
This macro exists in a Macro group that is enabled and set to be available in all applications, all windows, and always activated.
I've also tested that the Trigger is...you know "triggering" by swapping out my If Then Else action with a simple Alert action. (When I do this, I get the alert to fire.)
I'm sure my mistake is some super simple dumb thing that I'm just not seeing because I haven't used Keyboard Maestro in so long. What am I missing?
You didn't say how short the pause was, so my reply has a lot to do with testing if your pauses were sufficient.
You said "whenever that pesky window shows up". Does that mean it doesn't show up right away? If so, the quickest way to solve that is to insert a Pause statement before it. There are more reliable ways to solve that, but just for testing purposes, add a significant pause statement just to see if that fixes it. In fact, for testing purposes, add this action to the start of your macro for another test:
Hi @Sleepy. Thank you for your reply. I actually tested several delays but to your point, I could (and probably should) have been more specific there. I've done what you suggested with the 2 Second Between Actions Delay but that didn't seem to solve it.
And, to answer your question:
What I meant is that the hidden Teams window with the title "Microsoft Teams Notification" is not present when the Teams app is first launched. It's not until the app has been open for awhile that this window appears. But this is irrelevant to the trigger working / not working. I was just trying to describe the problematic behavior being exhibited by Microsoft Teams. I was not talking about Keyboard Maestro's behavior or the behavior of the Macro.
Now...for new interesting information: In adding the 2 second delay as you suggested, I discovered the Keyboard Maestro Debugger. With the debugger window, I see that the Macro was triggered, your Between Actions Delay is called out, then I see "If all conditions met, execute actions", followed by Type the Down Arrow keystroke then Type the Return keystroke. It seems the keystroke ⌃Down Arrow is being skipped!!! Any idea why that would be / how that could be fixed?
I agree that the window's appearance is irrelevant to the macro's trigger, because the macro is triggered when the app is activated. But then you said it takes a while for the window to appear. This means that the trigger will launch the macro before the window appears. I thought you wanted this macro to run after the window appeared, not after the app launched. When you do it manually, you said it works like a charm and I hypothesize it's because you don't do it manually until the window appears. Could I be right?
Don't worry about who's at fault for misunderstanding. I make plenty of mistakes and I just have to live with myself after making them. The goal is to help.
One day I told my doctor I couldn't hear out of my left ear. He starts by looking in my right ear. I said, "Doctor, that's the wrong ear." He said, "I know, I'm just establishing a baseline." Sometimes we need a baseline like that. So in this case I'm going to ask you to create a different macro with just an action to do a Control Down Arrow key. I'm not sure if you consider that to be a useless step, like looking in the wrong ear, but baselines are important when troubleshooting. If the new macro doesn't perform the CTRL-DOWN key, then that tells us one thing, but if it does, that tells us something else.
So....the Simulate keystroke ⌃Down Arrow action doesn't seem to be doing anything on my machine for some reason. This is interesting. See screenshot below. I've triggered this via the global palette. Also tried to trigger it from the menu bar, the Run button in Keyboard Maestro and the Try Action option for that action in the macro.
I'm also puzzled. This might be the cause of your original problem. We need to work on this problem now. I'm perplexed, but I don't give up easily. Thanks for accommodating my test request. It told us something important. We got lucky.
AHA. I may have a clue...
On my Mac, ^Down is reserved for some macOS shortcut. I'll bet that's the case with you too. I'm not sure how to solve your problem yet, but I think this is a part of the cause. We're getting closer.
Probably on your computer ^Down is not a reserved keystroke when in that app you are using. Some macOS shortcuts are app specific. I think we need to go into Sys Preferences and disable ^Down. Let's go looking for it now.
On my Mac ^Down is reserved for Mission Control. I'll bet if you uncheck that, your problem (may) be solved.
I am trying to get the macro to actually evoke the default macOS shortcut. The shortcut shows all windows of the front app. (You can see it in your last screnshot — fourth from the top.) My goal is for the macro (upon trigger) to show all windows of Microsoft Teams, then move to an alternate window of that application than the one that is mentioned in the IF statement.
Okay. At least we're 90% of the way to the solution, because we roughly understand what's happening. I have never used Mission Control so it would take me a long time to figure this out. Other people are probably much better prepared to solve this for you, now that we've come this far.
TL;DR: There wasn't anything wrong with my Macro! But something changed in recent versions of the macOS that prevent Keyboard Maestro's simulated keystrokes from being able to trigger (at least some of) the default Mission Control shortcuts. Switching away from arrows in the macOS system preferences shortcuts for Mission Control seems to fix this issue for other folks here on the forum and I can say that is also true for me.
I changed some of the default macOS keyboard shortcuts for Mission Control. (System Preferences > Keyboard > Shortcuts).
More specifically, I swapped arrows for keyboard letter equivalents as follows:
↑ is now W
↓ is now S
← is now A
→ is now D
I also exchanged ⌃ for ⌃⌥⇧⌘ so I could remap my new macOS letter using shortcuts to the old arrow versions within Keyboard Maestro. This makes it so I can keep using the old default muscle memory shortcuts for Mission Control functions like normal.
Here's a screenshot of how things look in System Preferences for me now:
I think these are fairly straightforward macros; but, in case it's helpful to anyone else, I've posted an export of my Mission Control remap macros as well as the macro I created to address the current Microsoft Teams ⌘Tab behavior. Note that none of these will work for you unless you also change your macOS keyboard shortcuts for these same Mission Control functions in System Preferences as indicated above but I would hope all in this forum who have read this far into this post would be smart enough to realize that.