It creates a new text expansion macro from selected text (as plain text).
The macro runs only with KM 8 or newer.
How to
In any application, select the text you want to create an abbreviation for.
Launch the macro via hotkey
Enter the abbreviation in the user prompt.
You'll see the abbreviation field pre-populated with a semicolon ;. This is the default abbreviation prefix and you can change it in the macro.
Make any adjustments if needed. You can adjust this in the user prompt:
Insert byâŚ
typing [default]
pasting
CaseâŚ
sensitive [default]
case insensitive
case affects expansion
regular expression
MatchâŚ
after any character
after word break
The "Match after" setting will remember your last choice, for the other settings you can change the default in the macro.
Hit Return
A new text expansion macro should now be created.
Extra Features
The new text expansion macro will be created in the same macro group where this macro lives. That is, you can drag a copy of this macro into any/each group (for example Global group, BBEdit group, MS-Word group, etc.) to create app-specific text expansion macros on the fly.
The name of the expansion macro will be generated from the expansion text. It will be sanitized a bit:
Linebreaks are replaced by the â glyph
Tabs are replaced by spaces
Length truncated
Note
Initially this macro was just a short test for the new AppleScript classes of the KM-8 Editor (macro, macro group, action, etc.). So, the macro has not seen much real-life testing ;).
Here an excerpt from the contained AppleScript with some of the new classes:
[âŚ]
tell application "Keyboard Maestro"
tell macro group id groupID
make new macro with properties {id:macroID, name:macroName}
end tell
tell macro id macroID
make new action with properties {xml:theAction}
make new trigger with properties {xml:theTrigger}
end tell
end tell
In the times when I wrote this macro I was trying to do the same
But it turned out that it somehow didnât work out. Currently Iâm using LaunchBarâs Snippets â via single modifier tap â to insert all my abbreviations; it is as fast as typing a fixed trigger (like with Typinator or KM), and more comfortable, because LB remembers your habitudes. For me.
Aha! Thanks for sharing
Out of curiosity, why did you decided to move away from typinator? For me it was the fact that it lags for too long when I am adding new snippets or editing them.
I will definitively look into LaunchBar! I didn't pay much attention to it yet, seeing that I use Alfred quite a bit.
I have no issues with Typinator, no lags so far. I just wanted to âstreamlineâ (thin out) my usage of background helper apps (LaunchBar, Typinator, KM Engine). So, I found out that â for me â LBâs Snippets are more comfortable than Typinatorâs (or KMâs) typed string triggers. If done via single modifier tap (this is important).
Question: does it have to be on the Global Macro Group for it to work? It just installed it again and it worked fined. So I moved it to another folder and then error happened again.
If with âopenâ you mean âopen for editingâ: You have to open it yourself in KM Editor. The macro is created in the same folder (group) as the creator macro.
If you mean ârunâ: Just run the macro via the typed string trigger you have set for it.
If it doesnât create a macro, make sure it is in a group that is activated for the app youâre in.
Hi @Tom - I'm essentially looking for a macro that opens the most recently created macro in Keyboard Maestro.
In other words, when I trigger this macro, it should launch Keyboard Maestro and go to the newest created macro (in this case, the text expansion word).
So, you could simply append an AppleScript action that uses this to open the created macro. (Or append the command directly to the existing AppleScript, inside the KM tell block.)
Maybe with a short delay before.
If you donât want to open each and every created macro, then you can wrap the action in a condition, for example if Option key is down, etc.
I tried placing this code inside the KM tell block of the existing Applescript (see below). Unfortunately nothing occurs even when replacing nteMacroID with macro id macroID or macroID.
tell application "Keyboard Maestro"
tell macro group id groupID
make new macro with properties {id:macroID, name:macroName}
end tell
tell macro id macroID
make new action with properties {xml:theAction}
make new trigger with properties {xml:theTrigger}
end tell
delay 5
editMacro nteMacroID
end tell
Yes, inside the AppleScript the KM variable nteMacroID is picked up by the variable macroID. (See the tell application "Keyboard Maestro Engine" block towards the beginning of the script.)
I donât know why it doesnât work for you. (You said you tested it with macroID too.)
This works for me:
tell application "Keyboard Maestro"
tell macro group id groupID
make new macro with properties {id:macroID, name:macroName}
end tell
tell macro id macroID
make new action with properties {xml:theAction}
make new trigger with properties {xml:theTrigger}
end tell
--delay 1
editMacro macroID
activate
end tell
The only additions are the 3 lines before the last end tell.
For me it works without delay, but this might be different with your setup.
The activate brings KM to the front (or launches it).
If it still doesnât work, check the Engine.log in ~/Library/Logs/Keyboard Maestro/.