Redesigned: Quickly Create an Auto-Correction Expansion With Typinator (Using Aspell and Typinator's AppleScript dictionary)

Howdy folks, I am really excited about this new macro and wanted to share it with everybody.

It is based on one of my other macros: Quickly Create an Auto-Correction Expansion With Typinator. But this is a completely new version with a lot more features, and is a lot more stable since it uses Typinator's AppleScript dictionary instead of GUI scripting. Therefore I am posting it separately from the other macro so as to (hopefully) not cause confusion.

==One caveat: to get the most out of this macro, you should also use Aspell== to get a list of spelling suggestions. More info on Aspell can be found here: Use Aspell (Homebrew Package) to Spell Check a Word. You can however simply disable the Aspell portions of the macro if you don't need any spelling suggestions; the macro will work fine without them, but you'll just have to verify correct spelling yourself. :wink: If you DO use Aspell, be sure to setup your ENV_PATH variable by following the instructions in this link: Create a PATH Environment Variable for Keyboard Maestro and Add /usr/local/bin to the Default Path - Questions & Suggestions - Keyboard Maestro Discourse

On to the features of the macro itself:

  1. Ability to use the same macro to for multiple sets by assigning multiple triggers.
  2. Searches your specified Typinator set to see if the misspelled word already exists (if it does, it is automatically replaced with the existing rule's expansion and you are notified [version 4.0.0+]).
  3. Automatically captures and filters any trailing spaces and punctuation and restores them upon pasting into front document (version 4.0.1+).
  4. Uses Aspell to provide a list of spelling suggestions.
  5. Option to set case handling.
  6. Option to set format to plain text or HTML.
  7. Option to add a description (by default it is a timestamp so you can sort by date added in Typinator.
  8. Option to set the expansion as a "Whole Word" expansion.
  9. Option to show the results at the end of the macro to confirm what you added.
  10. Option to paste the new expansion into your front document to replace the misspelled word.
  11. Option to open Typinator to the newly added expansion at the end of the macro.

Attached are several screen recordings of it in action.

I have been using this macro extensively since August 2021, and it has been rock-solid on my machines. But as always there is a potential for incompatibility on other users machines. So if anybody downloads and tries this macro and runs into issues please don't hesitate to reach out and I will try and help troubleshoot the issue as best I can. I would also welcome any feedback as to how the macro can be improved!


==NOTE: This macro makes use of the following KM version 10 action(s):==
Set Next Engine Window Position
If you are running a previous version of KM, simply disable or remove said action(s).

==CURRENT VERSION: v5.6.0 (Sunday, May 07, 2023)==

Version History (click to expand/collapse)

v5.6.0 Sunday, May 07, 2023
I added a step that upon pasting in a misspelled word that already exists in a Typinator set, retains the original word’s case.
This way you don’t end up with lowercase words at the beginning of a sentence, or uppercase words in the middle if that was the way they were originall added to Typinator.
NOTE: The way I have my sets configured, this will not change capitalization of names.

v5.5.0 Wednesday, March 01, 2023

  1. Added loop and error handling inside of AppleScripts to ensure they fully execute.
  2. Removed looping from Keyboard Maestro actions.
  3. Added notification of newly added entry

v5.3.0 Tuesday, January 17, 2023

  1. Added alert in case word is potentially spelled correctly.
  2. Modified AppleScripts to ensure Typinator is running.
  3. Added loop action to AppleScript actions to ensure the AppleScript finishes executing before proceeding.

v5.2.0 Thursday, November 17, 2022 (not posted publicly)

  1. Simplifed/eliminated some superfluous actions.
  2. Simplified RegEx to separate word from leading and trailing non-alpha characters
  3. Corrected an issue where in certain cases the original unfiltered named clipboard was being used for insertions.

v5.1.0 Friday, September 30, 2022 (not posted publicly)

  1. Used a switch action to move to end of work upon cancelling if it is already spelled correctly, otherwise leave it highlighted.
  2. Added deleting system clipboard (since I discovered that copying to named clipboard still makes use of the system clipboard)
  3. Added replacing straight apostrophes with curly apostrophes
  4. Added an action to retry the loop if the initial selection does not copy any alpha-characters (this can be handy if there is punctuation after the word you want to add since ⇧⌥← sometimes captures only the trailing punctuation, and not the word behind it).

v5.0.1 Monday, August 29, 2022
Improved RegEx to capture compound words before trailing punctuation as well as filtering out any leading non-alpha characters (in case the word is the first in a list) within one action.
Switched to named clipboard (Typinator) to prevent interference with system clipboard from Alfred's Clipboard Merging Powerpack feature.

v4.1.0 Friday, August 19, 2022
Added an option to manually type in the abbreviation in case it's not captured correctly.

v4.0.2 Tuesday, August 09, 2022
Improved RegEx to capture trailing spaces and extra space and restore them when the word already exists in the chosen set and is pasted in the front document.

v4.0.1 Monday, August 01, 2022
Modified filtering RegEx to capture any trailing spaces and puncutation to restore those characters upon pasting into front document.

v4.0.0 Sunday, July 17, 2022
Improved one of the AppleScripts to not only determine if the misspelled word already exists in the existing set, but in the case it does, to automatically repaced the misspelled word with the existing rule and alert the user to the replacement.

v3.2.0 Thursday, February 17, 2022
Finally figured out the proper syntax for case handling and expansion type.
AppleScript has been greatly simplified.

v3.1.0: Monday, February 14, 2022
Added 4 new features!

  1. Added the ability to use the same macro to add corrections to different sets by setting multiple triggers. The purple-colored variables need to be configured to meet the end-user's needs.
  2. Set case handling (case does not matter, case must match, case affects expansion).
  3. Set expansion format (plain text or HTML).
  4. Added a timestamp as the default description which allows the expansions to be sorted by date added in Typinator.

v3.0.0: Thursday, February 10, 2022
Completely redesigned macro.

Screenshots and screen recordings :arrow_down:

Screen Recording: Entry already exists (version 4.0.0) (click to expand/collapse)

Macro - 2 (entry already exists)

Screen Recording: Adding a new entry with 3.1.0 prompt (click to expand/collapse)

Macro - 1 (new entry)

Screen Recording: Show results feature (click to expand/collapse)

Macro - 3 (show results)

Screen recording: Using the suggestion provided by Aspell (click to expand/collapse)

Typinator auto correction macro (Aspell and AppleScript part 1)

Screen recording: Typing in a manual entry and description (click to expand/collapse)

Typinator auto correction macro (Aspell and AppleScript part 2)

Screen recording: Version 3.2.0 features: case handling and time stamp (click to expand/collapse)


Macro Screenshots (click to expand/collapse)

01)[AS-TYP] Create autocorrection expansion.kmmacros (150 KB)

Macro screenshot (click to expand/collapse)


@cdthomer, this looks really cool; unfortunately I don't have Typinator. (I have an old version of Text Expander, but wasn't using it enough to justify the subscription.)

What's the elevator speech for Typinator? I use KM for text expansion, so my interest would be the advantages it provides vs KM for these tasks.

Hey Jim, I too used Keyboard Maestro for text expansion for several years (even though I had Typinator that whole time too), but this last year transitioned to Typinator for any kind of text expansion that didn't involve other KM actions (like variables).

The biggest advantage to me for using Typinator is keeping my KM library smaller, and dedicated to much more complex tasks. To give you an idea of why I like this, in just one of my 30 or so sets, I have over 3,000 expansions. I have two other sets that have over 2,000 expansions as well.

I also like that Typinator has RegEx sets that allow you to use complex RegEx to insert text (probably doable with KM but I learned on Typinator so I stick with it). Also, I like Typinator's ability to expand abbreviations using AppleScript (also doable with KM but for me it's easier with Typinator). I also like that Typinator handles text expansion much more smoothly than KM since that is literally it's only job.

Anyhoo, hopefully that helps some. Let me know if you have any other questions about it!



Thanks, @cdthomer, it does, and you got me to the fifth floor with that nice summary! :grinning:

1 Like

Version 3.1.0 is up with 4 new features! See post 1 for more details.

Version 3.2.0 is up. The only change is simplified AppleScript thanks to finally figuring out the proper syntax for case handling and expansion type. See post 1 for more details.

This macro is not doing anything for me. "blah blah...Macros cancelled"...

Hello there! I’d be more than happy to help troubleshoot the issue if you could provide some more context. Please verify the following:

  1. Do you have Aspell installed?
  2. Have you modified the macro in any way?
  3. Can you turn on debugging or otherwise specify at which point the macro is failing?

Screenshots/recordings are helpful if possible too.

Yesterday @_jims and I helped troubleshoot an issue with one of my other Typinator macros that ended up being a problem with the users ENV_PATH variable not containing the proper file path for his installation of Aspell. Likely your issue is something simple as well.

Report back and we’ll go from there! :grin:


1 Like

Thank you for the fast reply.

1: yes, I have installed it via Homebrew
2: no modification
3: I don't know how to do that. It looks like no part of the macro has passed.

This forum is not uploading image for me.

No problem! Thanks for the info.

  1. Do you have an Intel or M1 Mac?
  2. Don't worry about the screenshot/recording.
  3. Did you set up the ENV_PATH variable?
  1. yes, I have Intel
  2. thanks
  3. No: is that the path for Aspell?

Ah that's the issue. And I now realize that my description in post 1 could have been clearer so I edited to include info about the ENV_PATH variable.

Check out this link to set it up. If you have any questions or run into issues let me know and I can walk you through it.

Create a PATH Environment Variable for Keyboard Maestro and Add /usr/local/bin to the Default Path - Questions & Suggestions - Keyboard Maestro Discourse

It doesn’t exist in the macro... it's a global variable that Keyboard Maestro uses to run Shell Scripts in the same way Terminal would run them.

Try this:

  1. Open Terminal
  2. Type Echo $PATH (or copy/paste from here)
  3. Press return :leftwards_arrow_with_hook:
  4. Copy the results into a KM variable called ENV_PATH
  5. Run the macro again.

To give you an idea of what the results would look like see the screenshot from my iMac with the results underlined in red:

Screenshot (click to expand/collapse)

Thank you for the clarification. It is working now.

Great! Glad you got it going. Let me know if you need any other help with it.

1 Like

Version 4.0.0 is now up. It automatically searches your specified set to see if the misspelled word already exists and if it does, automatically replaces it with the correct expansion. See post 1 for more details.

1 Like

Thanks, @cdthomer. This awesome macro gets even better. Thanks for sharing!

My pleasure Jim, this is one of my favorite macros I have built and have used it many, MANY times (as you can see in the screenshot). And this was just since combining them into one macro (with different triggers) instead of multiple macros. So i've actually used it far MORE than the screenshot shows but since initially it was 3 different macros I don't have the total usage count. :sweat_smile:

Macro usage count as of Monday, July 18, 2022 (click to expand/collapse)

Also, your skills are quite prodigious, so if you have any suggestions as to how I can improve this macro I'm all ears. :wink: :grin:

1 Like

Hi, thank you for your amazing macros. However, for some reason this one doesn't works with me. The previous version was good with me.

This one

I have aspell and every thing and I tried to debug it and the problem seems to be in the apple script when ever it reach there it crash.


Looking forward for your help