Do TextExpander Snippet - Plugin Action


Do TextExpander Snippet

by Ian Kirkland



Description

This plugin action is about as self-explanatory as they come: it executes a TextExpander snippet. This can be useful for a number of reasons such as triggering an expansion with a hotkey as opposed to a typed string. Who knows? You could probably create some interesting automations by pairing the action with things like Keyboard Maestro’s conditionals and Macro Information tokens.

To use, simply enter the snippet’s abbreviation into the text field and this action will do the rest. It’s worth noting that this plugin action executes TextExpander snippets via scripting, not by crudely simulating key presses.



Action

Enter abbreviation. Boom! You’re all set.




Additional Notes

  • As stated above, this action uses a script under the hood, not a miniature monkey typing abbreviations
  • I couldn’t find a way to trigger snippets by label / name without exhaustively looping into the DOM. If anyone knows a way, please let me know.
  • If you come up with any creative uses for the action, please share them here in the comments
  • Please report any bugs at: ianthekirkland@me.com



Download

Download Action:  Do TextExpander Snippet.zip (595.3 KB)



Legal

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


4 Likes

I can’t add the plugin. I’m dragging it to KM icon on dock but nothing happens. Is there any other way to add it?

Yes. Just unzip the file (which contains a folder with 3 files in it). Then put that folder into this folder…

~/Library/Application Support/Keyboard Maestro/Keyboard Maestro Actions/

Let me know if that doesn’t work, so I can (a) get you one that works and (b) make sure it isn’t broken or something.

Thanks for downloading!

Ian

thanks, it worked with the provided instructions.
it did not work when dropping the zip into the km icon though

thanks!

Hi, I’m using the plugin. It is quite useful.

I have 1 suggestion though, the message Invalid Plug In Results km-do_textexpander_snippet keeps appearing in KM log. Sometimes it makes difficult to debug other macros. Does this behaviour happens to you too?

Thanks for the heads up. Let me look into this. I’m thinking I might need to explicitly give a Keyboard Maestro Engine the equivalent of a ‘results=0’ or ‘result=null’. I’ll get back with you.

@eduardinho
I’m getting that same message. I’m getting it for nearly all my plugins though. Honestly, I can’t figure out what’s causing it. I’ll keep fiddling and if I find an answer I’ll post it here.

My apologies for the headache it causes in Console.

that’s ok. I only use console to debug some issues o it’s not frequent, but anyway. the plugin is really useful

1 Like

@ianthekirkland >> late to the party here - but thanks for this tool!

You asked for use-cases:

I have plenty of snippets surrounding specific phrases (in two languages) that I use frequently in emails.
They are to either respond to a request for a meeting, or to set up a new meeting, by using the Calendly service.

Thing is – I struggle to remember all my triggers, since there are about 8 of them in total.
I've now set-up a KM conflict palette, that only gets triggered in Outlook when using my Hyper+A key combination.
When triggered, up pops the conflict palette, whereafter I tap numbers 1-8, to select the snippet I want, which fires off the relevant snippet macro.
A bit convoluted, one might think – but really going to find this useful.

As it stands – going to roll this out across a couple of other snippet 'groups' as well!

So a belated thanks! Can confirm all appears to be working as it should on the latest TE 6.5.1

1 Like

Stupid question here, why do you need to use Keyboard Maestro to execute TextExpander snippet? Am I missing something here? Don't you just install TextExpander and off you go?

It's not a stupid question at all. I like managing my keybindings from a single application. Sometimes I trigger something and I wonder, "In which app/context did I set that hotkey/trigger?"

1 Like

If that's the came then I would love to know what other macros you've created? I can start:

  1. Morning and night setup macros - wakes Mac up and launches certain apps and URLs at certain times in the day.
  2. Plain text macro - doesn't work in Pages
  3. Macro for Photoshop - Basically shortcut for the stroke tool. Yes, I could give it a shortcut directly via PS but PS has so many keyboard shortcuts that it difficult to find an empty set of shortcut combinations.
  4. System info macro - A TextExpander snippet from a 3rd party.

Would love for someone to share how Macros are useful to them so that I get more out of Keyboard Maestro.

because my Keyboard Maestro is the basis to combine functions of different apps.
So also TextExpander @bocciaman

Here are a few older examples... until I would have created this only with Keyboard Maestro :wink:

Totally with you on the Photoshop thing. Hooking Adobe's keyboard shortcuts to something outside the Adobe environment is often a huge pain. Especially with apps like InDesign, where you get even more "contexts" in which a given keystroke will do certain things. The pros with Adobe apps is how much of their app DOMs they've exposed to Apple Events (e.g. AppleScript and ExtendScript). The cons are that if you can't conjure a decent solution, UI scripting is so horrendous, it's kinds of outta the picture.

Sometimes I'll set contorted keyboard shortcuts in Adobe that I'd never really use in real life because of how hand-stretching they are (e.g. CTRL + CMD + ALT + F5) and then map those to a "Type a Keystroke" macro in Keyboard Maestro.

I also, however, take advantage of things like "DefaultKeyBinding.dict".

You've touched on a topic I'm very passionate about and I will talk your head off for days about it. (I love nerding out on this stuff).

One system I've set up with Keyboard Maestro that I'm particularly proud of is the use of faux-modifier keys. It opens up a great deal of potential for more keystrokes and more specific contextual uses. For example, I have a macro that when I'm holding down [ALT + ;], temporarily enables certain other macros triggers until I release [ALT + ;]. This macro (see below) takes the text selection (or lack thereof) and wraps it with bookends (a 'pre' variable and a 'post' variable). What makes it special is that it's triggered by this key combination:

[ALT + ;] + [ALT + 2]

The reason for depicting the keystroke like this is because [ALT + 2] isn't enabled unless [ ; ] is down. And since [ALT] is already down, it's not necessary to include with the [ ; ]. It all sounds very convoluted, but is actually quite simple; If you've driven a manual/stick-shift automobile, it's a lot like a clutch.

Here's a handy example macro...which you can also use as a template:


DOWNLOAD KM MACRO: Text Wrapper - PHP Multiline Comment Selection - KMmacro.zip


ianthekirkland,

Thank you SO MUCH!

I downloaded as per your instructions and it is working fine so far with a couple of TE expansions in KM 9.0

This is exactly what I needed to put my KM macros into overdrive!

As you mentioned, now I can have a true source (TextExpander) for my text expansions but still have the option to call and use them from a Global Palette or even that new El Gato Stream Deck I am looking at.

again, thanks for all the hard work, it is much appreciated.

P.S.

Just realized I can do some amazing Terminal setups now and use my existing TE expansions that I normally type up by hand.

No more, hands are for losers, its all going to be automated in KM now.

HA!

That fact that you've found them useful totally made my day! Thanks for your feedback!!!

1 Like

You sold me on this idea. Can you please tell me how to execute TextExpander snippets through Keyboard Maestro?


Do TextExpander Snippet - Updated Plugin Action Set

by Ian Kirkland  |  Monday, September 2, 2019




Description

This pair of plugin actions are about as self-explanatory as they come; Both do the same thing (expand a TextExpander snippet) albeit in different ways. Do TextExpander Snippet expands by abbreviation, while Do TextExpander Snippet by Label expands by snippet label and group name, which is handy if you want to manage expansions via Keyboard Maestro (as a "single source of truth").

Both are plugin actions are useful for a number of reasons: triggering an expansion with a hotkey rather than a typed string (which you're limited to in TextExpander); managing system-wide triggers/keyboard shortcuts/etc. from a single interface (Keyboard Maestro); and more.

Who knows? You could probably create some interesting automations by pairing these actions with things like Keyboard Maestro’s conditionals and Macro Information tokens.




Do TextExpander Snippet (v 1.1) - UPDATED!

To use, simply enter the snippet’s abbreviation into the text field and this action will do the rest. It’s worth noting that this plugin action executes TextExpander snippets via scripting, not by crudely simulating key presses in the UI. This is an update to version 1.0, which can be downloaded here.

Changes in version 1.1:

  • Updated Icon

DOWNLOAD:  Do TextExpander Snippet v1.1.zip (101 KB)




Do TextExpander Snippet by Label (v 1.0) - NEW!

Enter the snippet’s group name and label and off you go! If you're wondering why the group name is necessary it's because we're triggering snippets by their labels, which don't need to be unique across groups. (e.g. If you had a snippet labeled "VueJS" in your "CND" group and a different "VueJS" snippet in your "HTML Includes" group, how would the TextExpander know which "VueJS" snippet to expand?)

DOWNLOAD:  Do TextExpander Snippet by Label v1.0.zip (102 KB)




Additional Notes

  • If you come up with any creative uses for the action, please share them here in the comments
  • Please report any bugs here or at: ianthekirkland@me.com



Installation

How to Install Keyboard Maestro Plugin Actions:
Keyboard Maestro has support for user written and contributable plug in actions. You can get more plug in actions from our web site or the forum and you can create and optionally contribute your own.

You can drop a new plug in action .zip archive on the Keyboard Maestro application dock icon to install it (note that to update a plug in action you must manually remove it from the ~/Library/Application Support/Keyboard Maestro/Keyboard Maestro Actions folder before re-installing it).
For more information, visit Installation of KM Plug In Actions



Legal

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

 
 

If you've already installed the plugin(s) (SEE MY UPDATED PLUGINS ON THIS PAGE), you just need to do the following:

  • Create a new macro in Keyboard Maestro
  • Open the actions panel and add one of the following actions to your macro:
  • Assign your Keyboard Maestro a trigger if you haven't already done so
  • Fire away!