Move or Click Mouse prompts No Front Window Found

I'm attempting to toggle the visibility of the clock in my menu bar via a keyboard shortcut and receive a "No Front Window Found" error when I trigger the attached macro. At the time the error appears, the correct window is the front-most and the only window visible on my screen.

I'm new to KM and therefor this might be related to my initial configuration. I have also not been successful being able to use the Select or Show a Menu Item action in other macros which prompt(which is why I'm assuming it might be a general configuration issue). I have turned on permissions for both KM and KM Engine in Accessibility>Privacy, have KM setup with Full Disk Access (but not KM Engine since it doesn't show up in a search) I'm running macOS 10.15.3 and KM 9.0.4 trial version.

Also note that my screen resolution is set to 1920x720 when the Macro was created and when it is applied (I use that setting when I record videos and want to hide the clock before I start recording).

I have also attempted to click the Lock icon in the lower left of the Date & Time preference pane and also receive a "no front window found" error, even though the window is open. If I manually unlock the pref pane and leave the window open before applying the macro, then the attached macro works. Note: in normal use, I am able to toggle the clock visibility without the need to unlock the pref pane.

Toggle Clock Display.kmmacros (3.7 KB)

I don’t get this error, but for me it doesn’t work either, because the click happens to soon. A pause action before the click fixes it for me:

56-pty-fs8
Toggle Clock Display [fixed].kmmacros (4.2 KB)

THANK YOU!

That fixed it for me as well. I'm new to KM, so I'll have to insert pauses when I'm troubleshooting my macros in the future.

1 Like

Here a more robust variant:

53-pty-fs8
Toggle Clock Display [alternate solution].kmmacros (1.8 KB)

Advantages:

  • Selects the correct tab of the pref pane (Clock)
  • Preferences windows stays in background
  • Clicks the checkbox directly, without screen coordinates

If it doesn’t work as expected: Uncomment the delay line in the script and experiment with different values.

1 Like

You just learned a very valuable lesson in KM. Adding or increasing Pauses will often fix an errant KM Macro.

As a general rule, you only need pauses before click actions, or after something that changes the focus, or occasionally after typing a large amount of text or otherwise performing lots of actions which can overwhelm the system.

There are other cases, and certainly for a failing macro it is useful to slow things down, if for no other reason than to see where things go off the rails.

I think that is a bit misleading.
I have found that you may need Pauses whenever you ask an App to do something the KM knows nothing about -- like select a menu or press a button.

You can always delete or reduce a Pause if you find out you don't need it.

You can certainly require pauses in other locations, and it will almost never hurt to add them and remove them later.

As a general rule, you should not need pauses after selecting a menu or pressing a button (using the actions) as they will generally be processed synchronously by the app, unless the button press results in a change of focus (or some other animating action).

Certainly if you perform some action that results in the application performing a task that takes appreciable time, then you will likely need a pause to account for that.

But again, I would say if you are having trouble with macro timing, the most logical places to put temporary pauses to debug the issue is before/after click actions, and after any focus change/animation causing actions.