[SOLVED] Help! I've Created a Macro That Has Basically Disabled My Mac!

I'm brand new, downloaded today and found a flaw that has permanently disabled every app on my iMac that has a small window. Here's what happened:

  1. I created a hotkey trigger for the number two, three, four on my keyboard.
    Two. I added the action to move the mouse to a location in the app I want to use and click. (420x875 I think)
    Three. It was working so well, I started exploring other triggers and actions.
    Four. I found the "when the active window changes/updates" trigger. (I was looking for a way to limit the triggers to the app I'm intending to use it with.)
  2. I clicked on it and the next time I switched the active window, which was almost immediately, Keyboard Maestro (KM) did exactly what it's supposed to do and moved the mouse and clicked.
  3. So now whenever I try to use an app whose window is smaller than the fairly large 420x875, KM switches away from that app super fast.
  4. I can't use KM to change the trigger.
  5. I can't use System to disable the service.
  6. I can't use the Terminal to disable the service.
  7. I can't use Finder to reinstall, uninstall, delete the app.
  8. I'm currently trying to figure out a way to disable the service or change my window sizes before they open.

If anyone has seen this before or has a suggestion for what I can do, please let me know. Thank you.

I agree with anyone who points out that I painted myself into a corner. ; )

I marked this as a bug because this is an edge case that probably rarely happens but completely destroys the functions of the app and possibly the entire system.

There must be a safety switch that allows a typical user to disable the service no matter what is going on with the triggers.

It's not an emergency anymore. I was able to force the window to get bigger by spamming the edges of the windows for the terminal to shut down the service. Then I was able to change my settings so that I could basically do the same for the KM window.

My suggestion would be to make the default application specific instead of global. That would at least prevent newbees like me from getting into so much trouble. I can't imagine what it would be like for someone who isn't confident with systems to handle something like this. They probably aren't the sort of people installing this either. I can't image what it would be like to try to to troubleshoot this if I didn't do this myself. I have a screenshot of the settings I used to get into this mess if anyone want to see how I painted myself into this corner.

I'm glad you were able to find a solution.

"I marked this as a bug because this is an edge case that probably rarely happens but completely destroys the functions of the app and possibly the entire system"

I think you would agree that it's not a bug when an application does exactly what one tells it to. The bug was in your macro, no? Keyboard Maestro gives the user a lot of power and so yes, there can easily be unpredictable consequences, but the same could be said of using the standard MacOS Terminal. Keep backups and tread carefully, but Keyboard Maestro is a solid and mature application so I think the risks are primarily in what we tell a literal-minded robot to do...

"My suggestion would be to make the default application specific instead of global"

I am not sure what you have in mind here. Remember that the scope of a macro (where it can be run) is determined by the Macro Group it is in. Do you mean that when a Macro Group is created, "Available in these applications" should be at the top of the list instead of "Available in all applications"? That would perhaps be an extra (and unpopular) safeguard, but then what happens when you add a macro to an existing macro group? If you don't check the scope of the macro group to which you are adding it, you have the same problem. And the same problem is essentially that we always need to check carefully what we're telling Keyboard Maestro to do.

"There must be a safety switch that allows a typical user to disable the service no matter what is going on with the triggers".

Keyboard Maestro > File > Quit Engine
or
"Quit Keyboard Maestro Engine" under the Keyboard Maestro icon in the menu bar
or
see other options explained at Troubleshooting [Keyboard Maestro Wiki]

K

3 Likes

Thank you for your response kevinb.

The macro I created prevented access to any KM interface functions, so using the KM menu to quit the engine was not an option. This was the case because the moment the KM window was selected the action clicked away from the KM window. This prevents the user from accessing the KM interface unless the click action is set within the bounds of the KM window. In my case the window was still at default which put the click target well outside it.

The reason I believe this is a bug is because I was exploring triggers that are activated and in force the moment they are selected. It's a great feature that I love because it's so responsive. The trouble happens when they are so responsive that the user doesn't have the opportunity to avoid catastrophe.

I'm still a KM newbee, but I get the feeling it's trivial to get into a loop that renders the average user incapable of recovering. I was close to reformatting my computer when I closed all my other apps and tried resizing the Terminal window with the mouse button held down. It proved successful after 10-20 minutes of fighting the constant switching. Once I had the window large enough to stay on the Terminal after the action, I was back in control.

Yes, the bug was in my macro, but it was nearly unrecoverable. Rapid and unconditional app switching is a risky action to automate because it can render the user incapable of interfacing with their applications. Perhaps a warning label or safety switch should be added to triggers and actions that have the potential to limit the user interface especially if they're Global. In my case, I had no idea selecting that trigger would instantly render every app on my computer windowed smaller than 890 vertical pixels inoperable.

I hope more experienced users will correct me if I'm out of bounds, but It seems trivial to have a safety on these types of triggers. Isn't it mostly the trigger that's the issue. As long as the trigger is safe the action can be prevented by not activating the trigger.

Here's are extreme examples for clarity:
Trigger: Every 0.001 second
Action: Sleep HDD (oops I meant to update my clock, but I misclicked on Sleep HDD)

Action: Format HDD (as an IT guy this would be a great action to automate if possible)
Trigger: Hotkey - Left Mouse OR Enter (oops, I didn't mean to do that)

Maybe there's no good solution for new or careless users messing things up. I'm as familiar with PICNIC as anyone. I just have a feeling theres something that can be done to prevent most of these types of situations. A warning for volatile triggers before they are active. Safety switches for powerful actions.

I think I'm arriving at a solution that might be tenable for everyone new and experienced alike. If only there was a master hotkey like a big red button on industrial machinery that is hardcoded into KM, like Alt-Ctrl-Del for windows. It is always available to end all macros or just kill the KM Engine altogether. It would mean anyone who goes through the tutorial and reads the part about how to get themselves out of a mess has a safety valve when things get out of control. It would stop macros so the user has a chance to change the problematic macro no matter how far they've painted in the wrong direction. What do you think of that idea?

Thanks again for helping me out.

Here's a screenshot of the situation I was in.

1 Like

Most KM users whether new or experienced sometimes forget that it’s possible they are not unique and someone may have come across a similar problem previously. The key is to remember that KM has a searchable forum and also user manual and so applying this leads to the following:

A key sentence from this tip is this

KM has already built-in this convenient feature

And you would do well to take a look!

There are other ‘kill switches’ available (I have two of them) - just do a search…

1 Like

"Quit Keyboard Maestro Engine" is also available from the KM menu bar icon -- using that shouldn't have triggered your macro. Failing that, reboot in Safe Mode and revoke KME's permissions in System Preferences->Security and Privacy (yes, I too have done a similar thing with a trigger!).

I'd have to disagree. The worst that a trigger can do is tie up your machine processing pointless triggers. It's the macro that the trigger runs that is the "danger", and that's utterly dependent on the actions in the macro. How is KM going to check every possible permutation of those?

In general, it's very difficult to protect users from themselves without really annoying users! And that doesn't just apply to the "new or careless" ones... So do some self-protection, which is always more acceptable because you chose to do it, not some nannying software writer :wink: . In no particular order:

  • Limit the scope of macros, especially during development -- if your macro was only enabled in the Finder or TextEdit you could have easily switched to KM for troubleshooting.
  • Consider your triggers -- updating your clock every millisecond? Bit extreme! Even if you do eventually want to do that, start with a larger time period so you can test properly. Setting a non-modified keystroke as a hotkey? Be aware of the consequences should you ever need to type that key for real!
  • Always have a way out -- as well as the KM menu bar icon and its "Cancel macro" and "Quit KME" options, look for the "kill switches" @tiffle mentioned.
  • Play defence -- put in checks and dialogs during development, you can always remove them once things are running smoothly. And in the same vein, don't override/auto-click application alerts/warnings without thorough testing...
  • Don't forget KM's Debugger -- open that, set it to "Pause new macros", and you can see the trigger fire and the macro start, but it won't do anything until you "Play" or "Step" through

And I'm sure others will have some more suggestions.

3 Likes

"Thank you for your response kevinb."

With pleasure, not least because there is always an opportunity to learn or revise when doing so. Keyboard Maestro can do a lot but is well documented.

"The macro I created prevented access to any KM interface functions"

Yes, I was trying to imagine what would still have been possible, including '"Quit Keyboard Maestro Engine" under the Keyboard Maestro icon in the menu bar', which surely should have been accessible.

"The reason I believe this is a bug is because I was exploring triggers that are activated and in force the moment they are selected. It's a great feature that I love because it's so responsive. The trouble happens when they are so responsive that the user doesn't have the opportunity to avoid catastrophe."

It's not unpredictable or erroneous behaviour. I think you are calling a feature a bug.

"I was close to reformatting my computer"

Blimey, don't reach for the nuke button... Check into how to restart your Mac in safe mode for the worst emergencies with any software. :wink:

"If only there was a master hotkey like a big red button on industrial machinery that is hardcoded into KM"

There's one listed in the link at the end of my reply. I didn't repeat the information because I think you would be better off reading the whole page.

Good luck with your macros and learning,

K

Haha, I didn't know that one.
https://en.wiktionary.org/wiki/PICNIC

I appreciate all the counseling I'm getting from this awesome community. I will be more careful and use the more advanced features of KM to limit the scope of my macros while I do testing.

One thing I wan to reiterate which seems to be missed by some people who are diligently trying to help is that nothing in the KM interface was available to me because the application could not stay in focus long enough to accept user input. You probably know how fast a mouse click takes for KM to execute.

Safe mode was the best solution to the problem if I hadn't figured out a way to expand my Terminal window. Of course reformatting is hyperbolic, but if safe mode didn't do the trick that would have been the only certain alternative. For me, that's too close for comfort even on a dev platform.

I look forward to learning more as I explore more of the capabilities and applications of KM in the future.

1 Like

Did you actually try the "Quit Keyboard Maestro" item under the KM menu bar icon (not the one in the KM application menu)? Mousing to and clicking on that would not trigger your macro above because the focused window doesn't change and, therefore, the focused window title doesn't change.

Asking because if that wasn't working then you had something else going on as well as the macro you posted above. That's another snafu to watch for -- a macro that does exactly as you want but in doing so triggers a second, which reverts you to the original situation, which triggers the first, which triggers the second...

Again -- been there, done that :wink:

1 Like

Nigee_S - I appreciate the TLC you're giving me to get me pointed in the correct direction.

I just want to make sure I'm not missing something since I straddle Windows and MacOS. If KM isn't the active window anymore, how would the menu bar still show KM functions? Like the first time I switched windows after setting up the problematic trigger/action combination. I don't remember whether I immediately cmd+tab or did so a moment later, but that would have been my next move to see what happened with that trigger. After that, the menu bar would only be on KM if Km was larger than 890 or whatever pixel height, which it wasn't. Either way, I set the trap the moment I started exploring the active window triggers, with a click away action.

Please let me know if I'm missing something.

The Mac menu bar has application menus -- File, Edit, etc -- that do indeed change with the active application. These (usually -- I'm sure there are exceptions, or utilities that can change this!) start near the left side and "spread" towards the middle of the screen.

Far left side is the Apple menu. Far right side and working towards the middle are menu bar icons -- Notification Center, Spotlight, Clock, etc -- which are present regardless of what application is active (again, I'm sure there are exceptions). Think similar to that slot in the Windows System Tray which holds "Eject disk" and other utilities.

KM has a menu bar icon, so there's a lot of useful stuff always available:

KM menu

As you can see, you start the Editor from it, paste from your Clipboard History, include frequently used macros and run them from there and, importantly, start the Cancel (by name or all) Macro and Quit Keyboard Maestro Engine. That last is a bacon-saver when you mess up a trigger, Cancel is good when your macro hits an endless loop or never-to-be-fulfilled Pause.

macOS is much more consistent IMO than Windows with what is "active" and the behaviour of "non-active" things -- for example, on the Mac you can click anywhere on a non-active window to make it active and that's all the click does, but on Windows if you click a UI widget in a non-active window it fires the widget's event. As a Windows user you should watch for that -- you can't have two apps side-by-side and one-click a button in either one, if the target window isn't currently active you have to activate it first then click the button.

(Pointing that out because, as a Mac user who sometimes uses Windows, I'm often caught out by this -- "I'll just click on that window to bring it to the... Whoops! That was a checkbox...")

Hey Dallin,

Here's one of those mentioned Kill-Switches:

Cancel / Kill All Running Macros

-Chris