I have a few hundreds ( ok I didn't count, but I have a lot ) of shortcuts stored in Apple's Keyboard Replacement setting ( System Preferences->Keyboard->Text screen ) that I would like to import into Keyboard Maestro.
Is there any automated way to do this? I created macro group for them, but don't know an automated way to import them.
No. Keyboard Maestro has no built-in importer for Text Substitutions.
But – can it be done? Sure.
Open the Keyboard Preferences and switch to the Text panel.
Select all of your Text Substitutions.
Drag them out onto the Desktop.
This produces a ‘Text Substitutions.plist’ file.
Run this macro to extract all of the Substitution/Shortcut pairs. Copy from the pop-up window and paste into TextEdit, BBEdit, or your favorite text editor.
Just a note here because I've known many people who did not know this... OS X/macOS text replacements sync to iOS and iPad OS. With hundreds, I'm guessing there are plenty worth moving over to Keyboard Maestro, but there may be some that are helpful to have in the Apple ecosystem (e.g., I definitely want the text replacement setups I have for my email addresses through Apple because I find typing email addresses annoying on the iPhone).
How it works, import a formatted text file with code and word on it, then the tool will process this file. all you need to do is select words you want to export to plist and press the export button, a list file with words in it will automatically generate on your desktop.
I have not tested a transformation to a KM expansion macro with this, but it's what is created when I drag my system text-expansions to the desktop from the macOS > Keyboard > Text prefs and they contain a “&” character.
For example, setting variable Expansions to the following text
something&somethingelse:12345
yields this error
/var/folders/s4/3q_b_3m90sxc6jbv3qq4yhw00000gn/T/Keyboard-Maestro-Script-3650A9CB-D738-4615-B799-8D4F183F7FE4:123:141: execution error: Keyboard Maestro got an error: a kmmacros file or XML must be supplied (-1)
Not a big problem for me as I just replaced the ampersand with a hyphen.
Yes, the code shown does not encode the input, so you either need to XML encode the input file, or add Filter actions to XML encode the input variables before inserting them in the XML.