Trying to activate app after wake up

I've scoured this site for answers, but nothing seems to work for my scenario.

Here is what I'm trying to do: while I'm still in bed, I'd like to wake my mac, activate MS Teams, type in "/busy". Whatever I do, I seem to get "Action timeout exceeded" in the logs.

I've set my Mac to wake at 6:30a each morning with:
sudo pmset repeat wakeorpoweron MTWRF 06:30:00

That part works fine.

Then I run one macro to enable the next macro:


That seems to work fine in the logs.

But this macro times out:

Relevant engine log section (ignore 8:30 time since I've changed for tshooting):

2025-03-27 08:27:00 Execute macro “set Teams Busy via search at 830a” from trigger At 8:27 AM Monday-Friday
2025-03-27 08:27:00 Log: Message mini March 27, 2025 At 8:27 AM Monday-Friday Firefox Firefox
2025-03-27 08:27:20 Action 158297 timeout exceeded. Macro “set Teams Busy via search at 830a” cancelled (while executing Activate Microsoft Teams).

Not sure what else to try, so please help.

I'm not sure if the following idea will fix it, but (what I would do is) instead of having one action to "Activate Teams" you could put it into a loop to keep trying. (Replace Finder with Teams, in both places. Make sure you have a reasonable timeout on the Activate action... I recommend 30 seconds.)

image

1 Like

That's a good suggestion, and I'll try it. I currently have the timeout set at 60 seconds, so it will try for a few minutes.

Unfortunately it still timed out. After thinking about it, I should have set the "Don't abort" after the Activate Teams.

2025-03-29 08:27:04 GetProcessForPID(1249) failed with -600 for <KBMRunningApplication “Microsoft Teams” <0x6000012aa730> pid=1249 bid=com.microsoft.teams2 abht>, using cached version
2025-03-29 08:28:00 Action 158297 timeout exceeded. Macro “set Teams Busy via search at 632a” cancelled (while executing Activate Microsoft Teams).

No! Abort is necessary for my macro to work.

Of course it will time out. In fact, it will time out multiple times. That's what my macro is designed to do. If it's not timing out repeatedly, then you aren't copying my code correctly.

Sorry I was not clear. There is an option for timeouts to abort script after timeout....I had that set to Abort, whereas I should have set to not abort. Will try again.

What "option" are you talking about? Please show a screenshot.

Either off the right click of Gear icon, checkbox:

or selecting "Set Action Timeout..."

When you said, "I should have set it to NOT abort" you were wrong. As I said in bold text, you must set to abort for my macro to work.

Of course, you aren't setting the action in my macro, either. I'm not sure why you weren't showing me the correct action in your screenshot. I was hoping you were going to show me which action in my macro you were insisting on disabling the abort flag, but you didn't show that.

I was on a different laptop, so didn't have the macro. Was just trying to relay what I was referring to in "Abort macro after timeout".

The current macro does abort as you recommended:

However I have many, many, failure messages in my log now. Here is a sample:

2025-03-29 15:18:07 GetProcessForPID(1249) failed with -600 for <KBMRunningApplication “Microsoft Teams” <0x6000012aa730> pid=1249 bid=com.microsoft.teams2 abht>, using cached version
Last message repeated 2 times
2025-03-29 15:18:24 Action 11097361 timeout exceeded. Macro “set Teams Busy via search at 632a” cancelled (while executing Activate Microsoft Teams).
Last message repeated 3 times
2025-03-29 15:19:04 GetProcessForPID(1249) failed with -600 for <KBMRunningApplication “Microsoft Teams” <0x6000012aa730> pid=1249 bid=com.microsoft.teams2 abht>, using cached version
Last message repeated 2 times
2025-03-29 15:19:24 Action 11097361 timeout exceeded. Macro “set Teams Busy via search at 632a” cancelled (while executing Activate Microsoft Teams).
Last message repeated 6 times
2025-03-29 15:21:08 GetProcessForPID(1249) failed with -600 for <KBMRunningApplication “Microsoft Teams” <0x6000012aa730> pid=1249 bid=com.microsoft.teams2 abht>, using cached version
2025-03-29 15:21:24 Action 11097361 timeout exceeded. Macro “set Teams Busy via search at 632a” cancelled (while executing Activate Microsoft Teams).
Last message repeated 4 times
2025-03-29 15:22:25 GetProcessForPID(1249) failed with -600 for <KBMRunningApplication “Microsoft Teams” <0x6000012aa730> pid=1249 bid=com.microsoft.teams2 abht>, using cached version
2025-03-29 15:22:44 Action 11097361 timeout exceeded. Macro “set Teams Busy via search at 632a” cancelled (while executing Activate Microsoft Teams).
Last message repeated 9 times
2025-03-29 15:25:40 GetProcessForPID(1249) failed with -600 for <KBMRunningApplication “Microsoft Teams” <0x6000012aa730> pid=1249 bid=com.microsoft.teams2 abht>, using cached version
2025-03-29 15:25:44 Action 11097361 timeout exceeded. Macro “set Teams Busy via search at 632a” cancelled (while executing Activate Microsoft Teams).
Last message repeated 2 times
2025-03-29 15:26:11 GetProcessForPID(1249) failed with -600 for <KBMRunningApplication “Microsoft Teams” <0x6000012aa730> pid=1249 bid=com.microsoft.teams2 abht>, using cached version
2025-03-29 15:26:24 Action 11097361 timeout exceeded. Macro “set Teams Busy via search at 632a” cancelled (while executing Activate Microsoft Teams).
2025-03-29 15:26:41 GetProcessForPID(1249) failed with -600 for <KBMRunningApplication “Microsoft Teams” <0x6000012aa730> pid=1249 bid=com.microsoft.teams2 abht>, using cached version
2025-03-29 15:26:44 Action 11097361 timeout exceeded. Macro “set Teams Busy via search at 632a” cancelled (while executing Activate Microsoft Teams).
Last message repeated 5 times

So now not sure where to go.

Getting the obvious out of the way first -- your computer isn't waiting for an unlock password, by any chance?

Is Teams properly installed in your Applications folder or is it elsewhere?

In the "Activate" action's popup, try changing the "Match" method:

image

You do need a "Keystroke: Return" action after you've type in /busy, else your status won't be set. And why go through the bother of enabling/disabling the macro? It's on a time-based trigger so won't execute unexpectedly -- no need to control it like you might a context-based hot keyed macro.

That repeating message is exactly what I was trying to test for. You did good. That means the problem isn't a GUI timing issue. I see that Nige has just given you some advice. His advice is generally twice as helpful as mine, so you should take his suggestions now.

Getting the obvious out of the way first -- your computer isn't waiting for an unlock password, by any chance?
It actually may be.

Is Teams properly installed in your Applications folder or is it elsewhere?
Yes, since the macro works fine when the laptop is not sleeping through the hotkey.

In the "Activate" action's popup, try changing the "Match" method:

Will change and try again.

You do need a "Keystroke: Return" action after you've type in /busy, else your status won't be set. And why go through the bother of enabling/disabling the macro? It's on a time-based trigger so won't execute unexpectedly -- no need to control it like you might a context-based hot keyed macro.
Yes, good catch. Changed that.

As for enabling/disabling, it was suggest on another message on this forum so trying to see if it helped.

Failed again, with this in the logs:

025-03-29 18:40:08 Execute macro “set Teams OOO via search - at 6p” from trigger At 6:40 PM every day
2025-03-29 18:40:17 GetProcessForPID(99409) failed with -600 for <KBMRunningApplication “Microsoft Teams” <0x6000012a34f0> pid=99409 bid=com.microsoft.teams2 abht>, using cached version
2025-03-29 18:42:09 Running application query took a while (1411683 us)
2025-03-29 18:42:09 GetProcessForPID(99409) failed with -600 for <KBMRunningApplication “Microsoft Teams” <0x6000012a34f0> pid=99409 bid=com.microsoft.teams2 abht>, using cached version
Last message repeated 2 times

Here is the latest version of the macro:

I found a post from the KM Architect himself about that error on this thread:

My suggestion is this: instead of using the Activate action, use the Move or Click Mouse action to start it. Doesn't that work for you already?

Another suggestion is to open the Console app which is in the Utilities folder in the Applications folder and turn on the streaming of errors. There's a chance you might see a more clarifying error message in there.

thanks for the assistance again. I'll see if that turns up anything.

Can you post the actual macro (not a screen shot) so we can test it? You'll find the instructions here: How to Post/Upload your Macros and Scripts

There's discrepancies between the shown macro and the log -- the trigger is wrong, there's no "Log" message -- which makes it difficult to be sure what's going on.

To be clear -- the macro is working when you use the hot key trigger, but erroring when using time-of-day? Is your machine awake and the screen unlocked when testing both triggers?

To be clear -- the macro is working when you use the hot key trigger, but erroring when using time-of-day? Is your machine awake and the screen unlocked when testing both triggers?

Yes, working from hot key trigger, but errors when I put laptop to sleep, have pmset wake up, and then execute the script at that point.

And yes, if I sit in front of the laptop at the time it wakes from sleep, the macbook sits at the login screen. Error logs shows that it was doing something in the background, but the screen doesn't show anything besides the login screen.

Here is the macro:
set Teams Busy via search at 632a Macro (v11.0.3)

set Teams Busy via search at 632a.kmmacros (8.2 KB)

If you don't login, your macro isn't going to be able to do anything, unless I've fundamentally misunderstood Keyboard Maestro for all these years. You're asking it to send keystrokes to an application, but it can't do that if you're sitting at the login window.

Please, someone tell me if I'm wrong about this, but I don't think I am.

-rob.

I don't think you are wrong, BUT if the login screen is actually an unlock screen, the KM Engine is still running. Many people don't know the difference between a login screen and an unlock screen.

Please, someone tell me if I'm wrong about this, but I don't think I am.