Keyboard Maestro vs. Alpha

I have been experiencing an issue that I’m not entirely clear on how to diagnose. This concerns using Keyboard Maestro with (among others) the editor Alpha (alphacocoa.sourceforge.io/).

I only recently acquired a new Mac with Big Sur installed, replacing a 12-year old Mac Pro. For some years I had relied on QuicKeys on that machine. On the new machine have returned after many years to Keyboard Maestro, which I had relied on prior to making the move to QuicKeys.

One set of personal KM macros I use frequently wrap text on the clipboard in HTML/CSS tags. For example, one macro takes a URL on the clipboard and turns it into a list item:

http://url.org/ ---> <LI><A HREF=“http://url.org“></A>

in a super-simple manner:

Insert text <LI><A HREF=“
Paste from the clipboard
Insert text “></A>

This seems to work fine in other text editors I sometimes use (including TextEdit and BBEdit), but in Alpha quite frequently (25-35% of the time) the inserted text is slightly garbled, with characters in the inserted text out of order from what’s specified in the macro, or occasionally just missing. For example, instead of "<LI><A HREF=“ what will appear is "<LI<>A HREF=“ or "<LI<A HREF=“ or "<LI<>A HREF=“ and similarly “></A> might become "“></>A” or ““<>/A>” or whatever. It’s not consistent, and I can invoke the same macro 20 times in a row and get 15 instances that are what they’re supposed to be and another 5 randomly mixed in with characters swapped around,, or occasionally dropped.

I’m guessing it’s something to do with the inserted text being inserted too quickly, or something of that nature? However, I have I tried to fool around with pauses in the macro and so forth, to no avail. I'm looking for suggestion that will help these macros run reliably. (I'm also posting to the Alpha help list for ideas.) Otherwise, Alpha is very fast and I have no other problems with it.

Thanks in advance.

For reference, here's an example as it currently stands:

Usually anything to do with keystroke automation, you may need to put some delay to improve reliability. Use this action to simplify putting delays between actions.

If I had to guess, the first thing I would try would be to make everything either “insert by typing” or “insert by pasting” rather than mixing the two.

1 Like

So far this seems to work fine. A delay of 0.02s seems plenty. Thank you!

Interesting suggestion. However, that seems to replace what was on the system clipboard with the first set of text that I was trying to insert by typing, yielding the result
<LI><A HREF=“<LI><A HREF=““></A>

Hey David,

No "seems" about it – it does – because the system clipboard is the only clipboard. All copied and pasted text go through it. All other clipboards in KM or otherwhere are pseudo-clipboards.

Try doing this:

image

-Chris

1 Like

Actually, come to think of it you're better off generally adding a delete-past-clipboard action to get rid of the newly pasted text.

Keyboard Maestro Actions.kmactions (541 B)

NOTE – Imported actions will drop right into the macro currently being edited.

-Chris

2 Likes

Now that's great. Thanks so much. I had no idea you could do that. It's a two-line macro now! (I also figured out how useful "Insert Token" is here.)

This one question has taught me a number of useful lessons as I become reacquainted with KM. Thank you everyone for your suggestions and assistance!

2 Likes

I didn't know that, that really clarified a lot for me.

1 Like

Hey David,

Make sure to scope out the Keyboard Maestro Editor's Edit menu carefully. Especially:

Insert Action › by Name
Insert Function › by Name
Insert Token › by Name
Insert Variable › by Name

Note the keyboard shortcuts – add or change as needed with Keyboard Maestro macros or with the System Keyboard Preferences.

Note also that holding down the Option-Key will turn many menu items into "Get help for this menu item".

The pop-up Insert... dialogs also have links to the selected item's help page on the Wiki.

Remember too that you can search for menu items using the search field in the Keyboard Maestro Editor's Help menu.

-Chris

1 Like