Create Text Expansions Macro

Apparently the switchers are on the way now. From the latest change notes:

6.9b2
• Typinator now also supports import from TextExpander’s “textexpandersettings” file format.
• When importing from TextExpander, Typinator now correctly converts nested snippet invocations.

(It’s on 25% discount now.)

Coupon KC8L will get you 30% discount.

You said KC8L will expire 8 April. It seems the new discount is unrelated to KeyCue.

The KC8L coupon is still working as of now. Perhaps it will expire at midnight tonight, I don’t know. It is easy enough to try both coupons.

Hi guys,

I’m sorry if this is some sort of highjack. But I do not get this working (have KM only a few hours, not into scripting at all. Should learn that - any good tipps/ressources?).

I’ve got a “.hi”-Snippet expanding to

"#!/usr/bin/python

from datetime import datetime
import sys

currentHour = datetime.now().hour

if currentHour < 12:
sys.stdout.write(“Guten Morgen,”)
elif currentHour < 18:
sys.stdout.write(“Guten Tag,”)
else:
sys.stdout.write(“Guten Abend,”)"

But I’m not sure how to switch that to KM. Can someone guide me on that?

Thanks!
Best

Absolutely NOT a highjack. In fact, your post is very ON-topic, whereas mine and the other above were off-topic.

Yep, see:

If that does not answer your question, please feel free to post back in the above thread.

One suggestion: Instead of using the “Insert by Typing”, I would use the “Insert by Pasting” action at the bottom of the macro.

1 Like

Why’s that please?

One feature of TextExpander I saw mentioned is the ability to automatically capitalize the first letter of an expansion, if it occurs at the start of a sentence (but not capitalize if it occurs elsewhere). Is that possible with Keyboard Maestro?

Not really, no. You can configure your Typed String trigger to “case affects actions” in which case the Insert Text action will honour the case of the typed string (Lower case, Upper first or Upper all).

So for example, if you had a trigger of “hello” and an insertion of “hi there”, then it would map:

  • hello ➤ hi there
  • Hello ➤ Hi there
  • HELLO ➤ HI THERE

But that’s about as close as it gets.

Thanks for the link. Gonna go through that if I have some spare time. Actually I bought typinator as well (and I do not understand everything, BUT the thing with regular expressions is HUGE).

A word of caution regarding Typinator. I used to use it, switched to TextExpander for a change in interface. Went back to Typinator today.

My OS went crazy. It seems that TotalSpaces2 conflicts withTypinator to the point that I had to disable TotalSpaces2. Use caution if you have both apps installed.

Hi, I'm a beginner to Keyboard Maestro, and am missing something simple about making OP's macro work. Can anybody offer some advice?

I'm not sure what OP means by

"simply fill in the text of the action with lines like:

trigger:text

where trigger is the Typed String trigger you want and text is the text you want to expand to."

I have tried to write in my trigger and text in different locations in the actions, but i'm not sure where in the actions it should go (i have tired the (.?):(.) area alot but not sure if i should be including the extra stufff). everytime i get a notification that says macro cancelled (pic below). Can anybody point me to exactly where i need to type the trigger and text? thanks so much!

This means, in the below Action, to replace the text of the Action with the text expansion trigger, and the text (snippet) that it will output, with your own, using the format of:
<trigger>:<text>

where
<trigger> is the typed string you will use to trigger the macro
<text> is the text snippet to be output

In the above Action, one of the macros to be created has
the <trigger> is "=em="
the <text> is "support@stairways.com"

Make sense?

1 Like

Yes!! makes complete sense now, thanks so much!

1 Like

(Only just on topic but) What interested me (apart from the whole confecting XML thing) is the use of a terminating character in a trigger.

For example, the second ‘=‘ in ‘=em=‘. It hadn’t occurred to me to use a terminator to aid disambiguation.

It also got me to thinking the technique of using Keyboard Maestro to confect other XML is great. For example, for z/OSMF workflows. (And then there’s confecting HTML.)

1 Like

Would love to know more about this... I assume you have some kind of system for these that makes them easy to generate/recall?

2 Likes

Hey Jon,

Many of those are spelling corrections that I don't need to remember.

I do make extensive use of sub-searches in Typinator, and in some circumstances I use key word/codes to make things easy to find.

Here's an example of the latter:

"h" is the sub-search code which is a mnemonic for "handlers" (my AppleScript handlers).

The prefix code identifies which library the handler is in.

So "h flb perl" will find any handlers that use Perl in my AppleScript "Find" library.

I use categories and sub-searches whenever something is likely to be hard to find.

I have something over 80 categories:

The "Date Strings" example above uses "ds" as its sub-search ID:

image

So it's easy to get there and find what I'm looking for (if I forget my direct abbreviation):

-Chris

5 Likes

Hey Chris, good to see you!
Great system! :+1:

1 Like

I'm populating the Expansions variable using the Read file to Variable action. This allows me to maintain and reference my list of text expansions in the text system of my choice -- currently Obsidian :tada:.

When I run the Create Text Expansions macro again I of course get duplicates created in my KM library. I'd be fine with automatically deleting all the expansions each time since the KM macro will add them back again, but I don't see any way to have a macro delete another macro.

Suggestions on the best way to handle this?

You can use AppleScript to delete all the macros within a specific macro group.

I suggest before running such a macro, you quit and relaunch the Keyboard Maestro editor, that way you have File ➤ Revert Macrs ➤ At Editor Launch available should you accidentally make a mess of your macros.

tell application "Keyboard Maestro"
	delete every macro of macro group "MACRO GROUP NAME"
end tell
1 Like