Add the contents off the clipboard as a Unicode expansion to Typinator

Just sharing; it might seem odd, Typinator functionality is replicated by KM but I don’t think KM can be scripted to create new macros or check for their presence—and for me Typinator does text expansion a little better—so I thought one or two or you might find it useful.

The link to my github below has an applesscript script which checks is the contents of the clipboard contains a unicode character or unicode decimal number; if it does, checks if there is an expansion for it already; if not pops up a dialog asking for an abbreviation.

I add it to this forum as I use KM’s clipboard trigger to launch it. The checks inside the script mean I don’t see many false positive dialogs pop up.

You can find it here.

1 Like

Keyboard Maestro can be scripted to create macros (see Create Text Expansions Macro and Create Text Expansion From Selection Macro for examples).

You can get info about macros from AppleScript, but it is in XML format, so it is a little hard to work with. However for this purpose, simply searching the XML from *getmacros with asstring" to “>UNICODE<” would almost certainly be sufficient to detect whether there was a macro already.

Fair enough. You showed how it can be done but KM doesn’t have any applescript objects to browse or create macros. We’re definitely in the realms of workarounds here :wink:

It would be nigh on impossible to have an AppleScript method to create macros, because that would require an AppleScript method for creating actions, which would be excessively complicated to say the least.

A more likely result would be extending Keyboard Maestro Engine’s scripting dictionary to include all the actions so instead of creating a macro you would write your macro in AppleScript. But even that would be astoundingly complicated.

I really don’t mean it as a criticism; KM is a very flexible product and I’m sure such flexibility is not simple to implement. However, other packages implement complex powerful Applescript APIs. KM doesn’t have to; it’s a matter of choices really and if KM chooses not to that’s fine and I wouldn’t have it any other way; I really doubt it is astoundingly complicated though, tedious and not worth the effort I can believe but not necessarily complex.

Users having to create XML though is not a great way to have to create macros. This should not be controversial a statement.