System Unlock Triggering Unexpectedly

This is rather odd. I've been working on mac and haven't locked or unlocked it during this time, but this macro triggered? I thought I had some other macros that also triggered at system unlock that didn't trigger, but those are actually triggered at wake, so I can't even guess if this is a macro, KM, or system issue. (Though I'm guessing system anyway.)

2024-12-12 12:02:58 Execute macro “BetterTouchTool- Restart after unlocking” from trigger At System Unlock
2024-12-12 12:04:29 Execute macro “BetterTouchTool- Restart after unlocking” from trigger At System Unlock

Nothing in the macro jumps out at me as a possible cause. N.b. I know BTT has a setting to restart itself after logging back in, but it was unreliable. Restarting it completely like this is necessary because it often glitches after the mac wakes from sleep and causing it to fail to process any triggers.

macro image

BetterTouchTool- Restart after unlocking.kmmacros (4.9 KB)

[edit] Okay this is really odd. I've been working on another macro, and the BTT macro seems to be triggering when I test it — though not every time. I'm trying to implement @Airy's MoveMouseToWord subroutine. It seems very straightforward, but I can't seem to get it to work.

macro image

Show Status Menu.kmmacros (2.8 KB)

2024-12-12 12:28:43 Execute macro “Show Status Menu” from trigger Editor`
2024-12-12 12:28:50 Execute macro “BetterTouchTool- Restart after unlocking” from trigger At System Unlock`
2024-12-12 12:29:46 Execute macro “Show Status Menu” from trigger Editor`
2024-12-12 12:29:52 Execute macro “BetterTouchTool- Restart after unlocking” from trigger At System Unlock`
2024-12-12 12:34:34 Execute macro “Show Status Menu” from trigger Editor`
2024-12-12 12:34:42 Execute macro “BetterTouchTool- Restart after unlocking” from trigger At System Unlock

You should define "can't get it to work." I.e.,

  • It moves the mouse to the wrong occurrence of the word;
  • It never finishes running, and I waited at least 30 seconds (remember, the first time it runs for any given word can take 10-15 seconds, but the second time will be instant if the word remains in the same location);
  • It finished, but never moved my mouse.

If you think there's something wrong with my macro, it may help you a lot to turn on the Highlight action at the bottom of my macro so you can SEE where it's looking for the word. Bear in mind that this will slow down my macro, but it will let you troubleshoot what it's doing.

Apologies. I was more asking about what might be causing it to trip the system unlock trigger, if that's even possible. (I didn't mean to ask two questions in one topic, but I didn't find the apparent connection until after I posted.) But what's happening is: the macro runs; the cursor never moves even when I would expect it to find the word on the screen; the macro carries on running presumably until timeout (though I've been cancelling it manually after 30+ seconds). Interestingly, in one attempt it found a different word entirely, but it's back to the aforementioned behaviour.

No, I'm sure it's user error, and I will carry on troubleshooting. I was just distracted/diverted by the other macro being triggered unexpectedly with it seemingly being connected to my testing a macro using your subroutine. Thanks for the highlight tip.

That's probably because the macro moves the mouse, as the name of the macro implies.

There's more than one possible reason for that.

My macro works best (faster and more accurate) when the words on the screen are large. If you increase the "font size" it will work faster but be less accurate, and vice versa if you decrease it.

I'm sorry, I'm not sure I understand. And I should've said system unlock not wake. My wake triggered macros are not affected, just this one using the system unlock trigger. The system hasn't been locked during any of my testing, but the BTT macro is being triggered whilst testing the macro using MoveMouseToWord.

Unfortunately I don't have any control over the font size since the word is a menu item in the KM Status Menu, which I'm realising might be the problem. Because if I close the Status Menu, the macro appears to finish without finding anything (since the word is now gone). I suppose there's some kind of limitation that prevents the macro from proceeding/OCR'ing/something whilst the KM Status Menu is open?

[edit] Further testing indicates that the ('not working') problem is indeed that the macro cannot advance while the KM Status Menu is open.

Wow! Great debugging there, pal. I guess the KM Engine freezes when that menu is open! That never occurred to me.

1 Like

I wonder if it's something to do with the OCR maybe? Actually it occurred to me as I was typing that maybe it's the Show Status Menu action that locks things up. Because I have this macro that can act while the menu is open. I was hoping to be able to replace the Find Image action with OCR and clean up the macro generally because it's kinda janky as it stands now. I always struggle trying to make hotkey toggles in KM (i.e. using the same hotkey to do/show something until the same hotkey is pressed again to undo/dismiss the thing). Much more testing is in my near future.

macro image

Keyboard Maestro- View Running Macros.kmmacros (51.1 KB)


As for the unexpected system unlock trigger behaviour, I have changed the macro to trigger on wake instead. :sweat_smile: I can't remember if there was a reason I originally used system unlock over system wake, but I guess I'll found out (or not, as the case may be).

That seems to be correct. The wiki makes no mention of this in the Show Status Menu action. The wiki probably should be updated.

One of the deepest lessons I've learned about programming is that when something behaves in an unexpected way, it may be possible to exploit that in some other context. In this case, this action has the unexpected side effect of freezing the KM engine. So perhaps I can dispense of my macro which "cancels all macros" and replace it with "Show Status Menu" which will (a) freeze the KM Engine, and (b) allow me to cancel all macros if I want, using the mouse on that menu.

1 Like