Redesigned: Quickly Create a New Expansion With Typinator (using Typinator's AppleScript dictionary)

Howdy folks, here is (yet another) Typinator macro, but this one will add any abbreviation to any set you have, be it a RegEx or normal set. It is quite similar to both my Redesigned: Quickly Create an Auto-Correction Expansion With Typinator (Using Aspell and Typinator's AppleScript dictionary) macro as well as my original Quickly Create a Regex Expansion With Typinator macro, but is far superior to the latter since it too (like the former) uses Typinator's AppleScript dictionary instead of relying on GUI scripting. Therefore I am posting it separately from the other macro so as to (hopefully) not cause confusion.

Now a little more about the macro itself, as well as the new features it has:

  1. Retrieves a complete list of all sets
  2. Allows you to enter your abbreviation using RegEx formatting or not.
  3. Selecting the checkbox "RegEx Set" (checked by default) will verify that the abbreviation has at least a basic RegEx formatting and prompt you to correct it if it finds errors.
  4. Will ensure that both abbreviation and expansion fields have data in them.
  5. Allows you to set additional options like "Whole Word", and adding a description.
  6. Can check the options to show the results as well as expanding the new abbreviation into your front document.

Attached are several screen recordings of it in action.

I have been using this new version quite extensively for several days now, 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!

-Chris

CURRENT VERSION: 4.1.0 (Tuesday, March 08, 2022)

v4.1.0 Tuesday, March 08, 2022
Changed abbreviation, expansion and description fields to different HTML tag to allow for resizing to facilitate seeing more info while typing.
Added form verification in the HTML.

Previous Version Info (click to expand/collapse) (click to expand/collapse)

v4.0.0 Saturday, February 26, 2022
Switched to custom HTML prompt for initial user input.
This has the advantage of showing additional instructions when you hover your mouse over each item.
See the custom HTML prompt screen recording to see a demo.

v3.2.0 Tuesday, February 22, 2022
Added more options for adding a custom description.
Changed actions order to add new rule to Typinator before user feedback.

v3.1.0 Thursday, February 17, 2022
Finally figured out the proper syntax for case handling and expansion type.
AppleScript has been greatly simplified.
Added default description to the current time stamp so abbreviations can be sorted by date added in Typinator (to disable this just delete the line out of the prompt).

v3.0.0: Thursday, February 10, 2022
Completely new macro, based on my original macro, but using Typinator's AppleScript Dictionary instead of GUI scripting.

Screen recording: adding a RegEx successfully (click to expand/collapse)

Typinator add expansion macro (part 1)

Screen recording: improperly formatting a RegEx abbreviation (click to expand/collapse)

part 3

Screen recording: forgetting one of the required fields (click to expand/collapse)

part 2

Screen recording: new custom HTML prompt (click to expand/collapse)

Typinator expansion custom HTML prompt

05)[AS-TYP] Create expansion from prompt.kmmacros (112 KB)

7 Likes

Version 3.1.0 is up. The only changes are a simplified AppleScript thanks to finally figuring out the proper syntax for case handling and expansion type, and adding a default description to include a timestamp and the expansion.

See post 1 for more details.

Update Monday, February 21, 2022: I noticed a typo in one of the AppleScripts in my personal copy today which I corrected and updated the macro here in case it was present in my public copy as well. No changes have been made and the current version is still 3.1.0.

Update Thursday, February 24, 2022: Version 3.2.0 is up with minor changes to the order of user-feedback options and a few additional options for the description.

Update Wednesday, March 02, 2022: Version 4.0.0 is up with a brand new custom HTML prompt to replace the original prompt. It has neat advantage of being able to show further information while hovering the mouse over each item in the prompt. Special shout out to @DanThomas for his help figuring out some specifics on the HTML and JavaScript.

1 Like

Is the Custom HTML prompt a separate file that needs to be downloaded? If so, from where?

Hey Rob, sorry about that, I might have uploaded my personal copy instead of my share copy. Try downloading it again, the HTML will be embedded in the custom prompt action.

Yes, that did the trick. Thanks for sharing this, by the way.

1 Like

You’re welcome! I’m all ears if you have any feedback.

Update Friday, March 11, 2022: version 4.1.0 is now up. Changes include the ability to resize the abbreviation and expansion fields to see more text while typing, as well as HTML form verification to ensure they are both filled out before submitting (previously done via KM actions).

See post 1 for more details.

First of all thanks for this macro, I use it dozens of time a day.

I suspect the last Typinator update broke it for me. I am now getting this error from Keyboard Maestro:

2022-05-08 10:22:06 Execute an AppleScript failed with script error: text-script:2753:2763: execution error: Typinator got an error: Can’t make «class » id "rule-600003abaa00" into type specifier. (-1700) in macro “05)[AS:TYP] Create expansion from prompt” (while executing Execute AppleScript to add entry to Typinator).

That makes my day, thanks for mentioning that!

Hmm... I just recently updated Typinator and am not having any issues. Can you give me a little more info? For instance:

Set Name
Abbreviation
Expansion
Options you are selecting etc.

I'm not sure why you would be running into that specific error as even when I was building this macro (and rebuilding and tweaking haha) I didn't run into that particular error.

-Chris

Strangely that error came up only for one set of snippets in particular. I was trying to save:

  • cleanshot > CleanShot X
  • clean shot x > CleanShot X

Just default options for a set I have used hundreds of times called "Product Names (Custom)"


On another note, how can disable the default check marks? I had a look into the macro but I am afraid of breaking something.

image

I guess what I meant by options was the options in the HTML prompt, like case handling and format.

I was able to add that to my Test Set without any errors. (click to expand/collapse)

I was able to add that to my Test Set without any errors.

To disable any of the default options, look in the purple-colored group of actions and change the contents of any of those variables to 0 (a boolean expression where 1 means true and 0 means false). See the screenshot for the three options you specifically asked about.

Screenshot (click to expand/collapse)

2 Likes

Hello @cdthomer

Your Macro looks very promising to me ... congratulations building such a nice looking HTML Prompt for the Macro.

Here some questions I currently have

  • will the Prompt be fully displayed on small Resolutions such as 1280x800 when Dock and Menubar are showing on screen ?

  • If not - could you eventually enhance the Prompt to show up on such "small Resolutions" ?

Greetings from Germany

Tobias

Hi Tobias, thanks for your commendation!

This was my first custom HTML prompt I wrote so i'm glad you like it.

Honestly I don't have the skill to write something for multiple resolutions, but I did some testing and here's how it looks on 1280x720 for me...

Screenshot (click to expand/collapse)

...granted the dock and menu bar are hidden but it is still visible on the screen, albeit the entire height of the screen haha. But if you run 1280x800 then you have a little more vertical space and it would probably look just fine.

Greetings from Ohio,
Chris

Hello Chris

you're welcome

I am currently trying to learn some HTML stuff because I have several KM Projects in planning where I need to have the skills for writing HTML Prompts - I know that there is a way using CSS & Sass with Grid and Flexbox to make Websites responsible to what ever Dimensions .... but I don't know If this could be done in the Code for KM's HTML Prompt.

but - and that would be up to you - there could be a way without adding too much complexity to the HTML Code if you let the Macro handle the Resolution of the Display and show your Prompt in a slightly different layout. But this would require that you'll have to add at least one more HTML Prompt to the Macro....

yes - I run that Resolution .... I have a MacBook Pro 7.1 13" from mid 2010 that uses this Resolution as its max.

another thing I'd like to see is if you could change the Variables .... I've seen that you are using Local Variables whose are one Word and start with a lowercase "L" maybe you could use something like "Local__VarName" - but that is up to you - I use to write all my Local Variables like this.

Greetings from Germany

Tobias

I imagine everything could be combined into one HTML prompt since CSS at least can be embedded directly in it, but I wouldn't really know how to dictate to the HTML which dimensions to use.

I wrote the macro like that initially since all my macros are prepended local__ or instance__ etc., but for whatever reason I can't remember now they were not being passed correctly to the HTML. So I had to rewrite the variables to remove the underscores. I think it had to do with them using double underscores... but it's been a few months and I just don't recall. Honestly at this point I won't look into it again since the macro works and they're local variables so I never really need to interact with them elsewhere like I would an instance or global variable.

Yes it could be combined into only one Prompt but - and that is the thing we don't know how to deal with at the moment ....

Because of that I had the idea to write another layout and let the Macro be the Brain and decide when which Layout has to be presented to the User.... but that is only an idea

hmm .... that's odd ...

Ah ok I follow you now. Well I’m not opposed to that idea, I think it would be rather simple and just a matter of adjusting font size since the table layout isn’t really set to specific sizes, but rather proportions based on the text size. I’ll put it on my back burner and if I have some time to tinker with it I will. :+1:t2:

1 Like