Macro Is Unexpectedly Launching An Application Every Five to Ten Minutes

I created a workflow to resize an app's window when it launches (the app, annoyingly, doesn't remember its own window size). But now that app is being launched every 5-10 minutes without any action on my part. The workflow trigger is set for when the app launches, so KM shouldn't be launching the app, only responding when the app is launched. If I deactivate the workflow or quit KM entirely, the app no longer launches, so it does appear that KM is causing the app launch. Any ideas on how this is happening?

1 Like

That can be frustrating. What does the engine.log file say is triggering the macro?

Hey Lucas,

It's impossible to say without seeing and testing the macro in question. If we're not testing we're most likely guessing, and guessing often wastes people's precious time.

Please post your macro, so we can see what you're doing.

When posting macros to the Keyboard Maestro forum please use these guidelines:

  1. Always Post a Macro File.

    • This means people won't have to reinvent the wheel to test your macro, and that significantly improves the likelihood that someone will help you.
  2. Always Post a Macro Image.

    • Folks generally won't download something they haven't eyeballed first, so an image of the macro is crucial.

If you haven't seen these they're worth a moment of your time:

Tip: How to Post Your Macro to the Forum

Macro: Automating Sharing Macros or Actions to the Forum

Tip: How Do I Get The Best Answer in the Shortest Time?


--
Take Care,
Chris

(Keyboard Maestro Moderator)

3 Likes

I'm trying to resize the GoodNotes app window when it launches because it doesn't remember its window size between launches. My macro should only trigger when GoodNotes is launched or activated, but somehow GoodNotes is launching on its own when KM is running and this macro is enabled. Is there anything in the macro's setup that would be causing this? Is this a KM bug?

macOS 12.6
Keyboard Maestro version 10.2
GoodNotes (for Mac version 5.9.56)
MacBook Pro (14-inch, 2021)

GoodNotes - resize window 1.1.kmmacros (18 KB)

I'm not very familiar with Console or reading through the log files. I'm not seeing anything that indicates what's launching GoodNotes (the app in question). Looking through Console > Log Reports > Engine.log is what I think you meant, and it has the most relevant entries, but I'm not seeing any that refer to launching GoodNotes, only the triggers to execute the macro that runs when GoodNotes launches or activates.

Am I looking in the right place? Any tips on what to look for—both where in Console and what would indicate a trig for an app's launch?

I'm not very familiar with Goodnotes, but is it possible it leaves something running (a menu bar launcher, or some kind of background indexing process or something)? Perhaps that is getting "activated" and triggering your script?

There is nothing in your Macro to launch GoodNotes (apart from the one disabled Action you have to "Activate GoodNotes").

But I'm not sure you need both triggers (Launched and Activated). When I tried this double-trigger with TextEdit my test Macro fired twice when TextEdit was launched. A single "Activated" trigger will work for when an App is either launched or switched to - in other words it will cover both situations.

In fact you now have it set to fire for when the App launches and when it is switched to. if you only want it to run once when the App is actually launched you should go with the single "Launched" trigger.

To test whether it is the trigger that is causing the problem you are having, you could temporarily remove all your current triggers and give the Macro just a hotkey trigger and fire it manually. If the problem goes away you know it is something to do with the automatic trigger.

Here's a slightly cleaned up version of your macro -- it won't stop GoodNotes auto-launching, but it might make things easier for you when you come to tweak things.

GoodNotes - resize window 1.2.kmmacros (12.1 KB)

Image

You don't need all that business with the screen shot -- you can get your main screen's width directly with SCREEN(Main, Width) and use that directly in your "If..." action. Your second "If... ScreenWidth is 3024" may or may not be true -- it doesn't matter because any window resizing you do there is overridden by the final resize action.

You don't need to re-size then scale, you can do it all in one go. And since you are always centering the window, whatever its size, you can use one action at the end rather than one per window size.

Thanks for the newer version! It's great to know a better way to identify and use screen size settings, plus I learned better how to use the screen size fields. I thought there was a better way than I'd used originally, but I didn't know and didn't find any settings with my cursory search, so I hacked together my original approach.

Update … fixed?

Thanks for everyone's input.

I have not had GoodNotes launch in the background for a number of days, nor I have figured out why.

But I have a hypothesis: I think it is possible that GoodNotes was launching in the background because of the following combination of factors…

  • Early versions of my macro didn't consistently resize the GoodNotes window when the app launched so I added some actions to try to make it more reliable including activating the app to make sure it was the front app. Those actions helped but the macro still wasn't 100%.

  • The action timeout settings in earlier versions of the macro were not adjusted from defaults so they had very long timeout settings, and failed actions were not all set to terminate the macro.

  • So I think what may have been happening is that multiple instances of this macro were triggered but they weren't all successful, and when an action finally timed out and the macro continued, the macro could then activate/launch the app in the background because I'd long since left/quit the app.

  • And since the app was being launched again and again the macro was running again and again, not always successfully, but enough to have another instance of the macro running that would again later trigger the app to open. Having my computer and the KM engine running for days before restarts meant this random background launching could occur for longer periods of time without being killed.

Anyway, that's my guess.

In the process of cleaning up the macro in many ways, including the timeout settings, this series of events occurred to me, and it's my best hypothesis so far since I haven't been able to track down other causes.

I've also not had the background app launching occur since I've been using newer versions of the macro that would prevent the background launching from happening.

Hey Lucas,

I have the Keyboard Maestro Status Menu visible in the macOS menu bar.

I also use the Iconaholic Loud icon set for it.

2022-11-28_00-32-19 (1)

This way I am painfully aware when Keyboard Maestro is running and shouldn't be, and that has seriously saved my bacon (along with a kill-switch macro) about four times over the years.

It has also alerted me many times to things not going quite as planned.

-Chris

3 Likes