Getting opt+u to work both as a desired task in one case and as default behavior in all others

Hi everyone,

Forgive this question if it's overly simple or if it's been answered a lot in the past.

I'm trying to create a macro where the key command opt+u does a specific task in an app when a menu item is selected. I'm trying to create it using an if-then-else bracket and am successful up to the point in that the "if-then" part of it works fine and the desired task works as expected when the menu item is selected. The "else" segment does not, however. When it's "else", I'd like opt-u to create an umlaut as it does by default in text applications. When "no action" is specified in the "else" part of the bracket, nothing happens when I type opt-u. I tried looking for a function in Keyboard Maestro which returns opt-u to it's default role in text applications, but couldn't seem to find one.

Once again, my apologies if this topic has been covered in the past, but any advice would be greatly appreciated.

Assuming you are wanting to use ⌥U as a Macro Trigger, my first suggestion is to keep things simple, and use some modifier key with the ⌥U when you want to use it with the selected menu.

However, I'm not sure I understand your question/macro. Please post/upload your macro (note the instructions to upload to an existing topic) so we can see exactly what you are trying to do.

The Else action should be Type Keystroke option-u.

It is highly recommended to NOT type a keystroke which is the same as the Macro Trigger in the Macro that contains it. @peternlewis has stated more than once that results are unpredictable.

You and I have discussed this elsewhere. All I can add is that it has always worked for me, and I have never been presented with an example of it doing anything else.

You can, of course, do as you like. I would not, however, want to suggest to others something the app developer has repeatedly stated can produce unpredictable results.

I can appreciate that, but there's a difference between "can produce unpredictable results" and "does produce unpredictable results". I'm just asking for evidence.

It has produced unpredictable behaviour in the past. The behaviour has changed from version to version, and can change based on the load of the Mac. If the Mac (or target application) gets loaded down enough then the simulated keystroke can remain the the event queue long enough that Keyboard Maestro re-enables the hot key, and thus re-triggers the macro.

So keep this in mind that it should be avoided if possible, and failing that you should consider what the consequences will be of the macro being triggered (potentially triggered many times if triggering the macro simulates the hot key that would re-trigger itself). As long as the consequences are minimal, then you should be ok.

But regardless, it is not recommended - if you can find another way, that is advisable.

Thanks for the numerous responses. I did try thoffoman666's advice of making the Else action "Type Keystroke opt+u". And it works—most of the time. This seems to corroborate JMichaelTX's assertion that making the macro type a keystroke that's the same as the macro trigger in the macro that contains it causes some instability. However, it works decently enough that I'm willing to accept some unpredictability.

I'm uploading both the macro and an image of it if you'd like to take a look and see if there's a more efficient and reliable way of doing this. Thanks again for the feedback, it's very much appreciated.

Use Selected Staff Style For Scores And Parts.kmmacros (3.8 KB)

If the intent of using option-u in the Else is only to insert an umlaut, then you could replace the Type Keystroke action with Prompt User With List action that allows you to choose from the various umlauted letters.

Like this:

If Then Else.kmactions (2.7 KB)

1 Like