Create a Popup Menu with Text Templates from a Text File

This Macro reads the content of a single Textfile and parses it into a Popup Menu. Once an entry from the Popup Menu is selected, it pastes Text into the active App.

The Format of the Textfile is:

Title#Template(RETURN)Template...

The Popup Menu will show only the "Title" part of each line. If an entry from the Popup Menu is selected, the file will be read again, to compare the selected Popup Menu Entry with the "Title" part. If there's a match, the "Template" part will be reformatted by replacing all (RETURN) with a line-break. Afterwards, the "Template" part text will be pasted into the active window.

I am using this for an Email Templates Collection, f.e..

If you know a way to improve this or have a better solution, please share it with us here.

Thank you.

Email Templates.kmmacros (28 KB)

Hey There,

I recommend that you use home-folder-notation for Posix-Paths where applicable.

~/Dropbox/Apps/Email Vorlagen/vorlagen.txt

Doing this makes them more portable hard-coding the path.

If you rename your user it will still work.

If you rename your disk it will still work.

If you move to a new computer it will still work.

-Chris

Thank you. :thumbsup:

Found 1 error right at the start. The Titles Variable must be cleared instead of the Templates variable.

I have now inserted:

Get Substring of Variable ‘Titles’
Subrange deleting last 1 characters.

right before the Prompt for User Input is opened, to avoid an empty last entry in the Popup Menu.

Updated Macro is attached (but now with german text in the Prompt for User Input Window.

Email Vorlagen.kmmacros (28.7 KB)

Have you ever tried/used the TextExpander app?
It does a similar thing for templates, and much more.
I use it many times a day.

Yes. I come from PhraseExpress on Windows and had many hopes regarding the evolution of TextExpander. but it is still after years, just a “dumb” TextExpander. :stuck_out_tongue_winking_eye:
I have it on OS X and iOS and do not use any of em.

Why should i install another Text Expander beside KM? KM can achive anything TE can and MUCH more. :smiley:

For me the reason I have chosen to stick all text expansions in TextExpander is I find it pretty nice to search and add new stuff quickly. The sync version to the iPad is finally usable across all iOS apps thanks to Apple allowing custom keyboards. Plus it is a real boon for me for apps that natively support TextExpander in iOS, especially in OmniFocus 2 for the iPad to have everything just expand quickly with with custom times and dates, to me it's a little more than just a dumb text expander, but that's just me. I also like that it reminds me when I type things out that I have already created a snippet for.

I see the benefit of course in not running too many apps and keeping things consolidated in folders in Keyboard Maestro too. I seriously considered putting all my text expansions in QuicKeys years ago since it had an entire section dedicated to this feature and did it well.

I also kind of like the "Suggests snippets from phrases you habitually type" feature in TE5.

1 Like

I like and use both KM and TextExpander many times a day.

First of all, TextExpander is far from a "just another dumb text expander". They offer a free trial and you owe it to yourself to try it out.

KM and TextExpander are two totally different apps, with quite different purposes and uses. There is some overlap, but not much. One of the biggest difference is that it is extremely easy to add a new TE snippet, or edit an existing one.

I currently have over 150 snippets in TE. I use them for pasting commonly used text in various apps. For example:

  • Answers to FAQ in various forums
  • Frequently used code snippets in AppleScript and (soon) JXA
  • Forms/templates (with user input) to paste into Evernote
  • Various date/time formats
  • Various email addresses
  • Various email signatures

There is no way I could begin to remeber 150+ shortcut keys, even if there were that many available. Instead, I have a naming convention that is easy to remember.

I'm sure I could create KMs to paste the snippets, but a KM macro is much more time consuming to create than a TE snippet. With TE I simple type in the text, or most often, paste in the text I've previously used somewhere, and enter the expansion code, and the snippet name, and I'm done, all in less than 5 min, often only 1 or 2 min.

I also have about 70+ KM macros, probably only 50 active, and there is NO overlap with my TE snippets.

I could not get along with either KM or TE.

JMichaelTX, would you share your easy TextExpander naming convention? I have searched and searched for an answer. Nothing is really satisfactory for me so far.

I started a new topic to respond. See:
TextExpander Naming Conventions

Hey Michael,

I have 47775 snippets in Typinator.   :sunglasses:

Many of those are auto-corrects and the full listing of U.S. Zip Codes, but well over 3000 are mine.

I'd hate like hell to manage them in Keyboard Maestro.

KM does snippets well but not as well as a dedicated utility (and we've had this conversation before on the forum).

I own TypeIt4Me, TextExpander, and Typinator and have been using this type of utility for about 25 years now. I swear by them and am always flummoxed when users blink and say "I never use them." or "What good are they?"

Of course I've been using Keyboard Maestro as long as it has existed — which long predates Peter's acquisition of it.

PhraseExpress on Windows is outstanding by the way.

-Chris

1 Like

Ah, you're just bragging now. Or telling us how ancient you are. :laughing:

Roger that!

Hmm ... so what do you do with zip code snippets?

Hey Ed,

I have them in a searchable sub-list, so I can quickly look-up by city, state, or zip-code.

I don't use them very often, but on occasion they're handy.

I have several searchable "databases" set up this way.

-Chris