Simple text expansion in KM or Alfred?

As basic as my macro is, I didn’t realize that I could do that in KM or Alfred. I don’t use Alfred except as an app launcher but I had the Powerpack.

Yesterday, I found out that I had v2 Powerpack but I was running Alfred v3.

I downloaded v4 and now will purchase the Powerpack. I listened to two recent MPU eps that talked about Launchbar and Alfred and I want to improve my workflows and I think there are some really basic things I could use it for to make my life easier.

I have KM and had gotten the Karabiner app but never got that to work properly to map my Caps Lock key. I’m hoping that also works when I get a new laptop.

1 Like

ahhh, I think your work horse did 7 years of fairly hard service, that is really the problem here I think?

I use Karabiner just for the Caps lock trick. It is really useful you will love it, again that should work ok and it doesn’t for you. As long as one is careful with permissions.

I wish somebody would pile in really and say why, for a small number of snippets TE is more useful? Even for larger numbers of macros there are strategies to save RAM and plist space. TE is a nice app and I do like it I will say. I just like Keyboard Maestro more. Or somebody would come in with a kind of limit for Keyboard Maestro. Like what is the sensible number of snippets over which one should use TE? I have no idea of the answer and haven’t the capacity to experiment. @MacExpert any views? @MacSparky what is the limit on the number of snippets one can have on Keyboard Maestro before one needs TE? See I rely on a small number of macros and snippets, but without them, this would be a different machine.

I always use Insert text by typing, as I’ve had some issues (don’t recall what) with pasting text. The side effect is the clipboard is not replaced.

I have 299 macros.

  • 102 are words that appear in a palette for use as keywords in my reference manager and DEVONthink (to avoid spelling errors, duplications, etc.)
  • 50 are special characters like :g: is 𝛾 (gamma), etc.
  • the same 50 also have a LaTeX equivalent, so typing :g: is \textgamma{} when that palette is active.
  • A half dozen for different date formats.
    • ddth=Dec 4, 2019 12:33 PM (date date time human readable)
    • ddh = 2019-12-04 (date date human readable)
    • ddt = 20191204123451 (date date time)
    • etc.

Then I have several that use the hyper key (CapsLock remapped using Karabiner-Elements) to trigger different things, Hyper-P toggles my VPN, Hyper-T opens a Terminal window at the current Finder folder, etc. CapsLock by itself (just tapped) opens Alfred.

1 Like

Interesting. I hope other pitch in. I used to use ‘type’ but I went back to pasts and put a ‘delete past clipboard’ action to stop clutter. Again since I have a small number the extra action is irrelevant to me when setting them up and I keep that in ‘favorites’. I like to use ‘type’ if I can, even for longish ones, just to watch it happen.

1 Like

I have twenty snippetts and 105 macros in total. Without them I would be totally lost. I have about 20 in that must have category. If I remember right you use LaTeX ? is that true. Do you use any snippets for that. I don’t I tend to use templates I save as I use my own formats mostly now and very little formulae and that kind of thing. I love LaTeX though and use it almost for old times sake. I still think it produces a good looking pdf though. An impressive one.

I wanted to give all the kind people here some closure.

I got my new laptop yesterday and spent a bunch of hours setting it up. (I’ll spare you the details of getting a bad laptop which I had to return.)

It’s amazing how many pieces of software I loaded because I rely on them on a daily basis.

Anyway, I made the KM macro that started this whole thread and it worked perfectly. So there must’ve been some sort of conflict preventing it from working on my old laptop.

So thanks again for all the help.

But as I was going through this thread again, I wondered if KM or Alfred would be the better choice, if one had both installed. But unless I don’t know how Alfred snippets work, wouldn’t one have to invoke Alfred first and then run the snippet?

1 Like

Come on Apple/Foxconn. Do better.
image

Alfred snippets work without invoking Alfred first. I have a library of Apple symbols in Alfred for things like the command key, option key, etc. symbols. The library is in Alfred because someone made it available and I could import it, rather than creating by hand.

Glad you got things working. When all else fails, replace the computer :slight_smile:

1 Like

Good to know about Alfred snippets working without invoking Alfred first. Thanks.

I haven’t had the Powerpack for probably a couple of years (without my knowledge) so I’ve been debating on whether I should get it since clearly, I may not need it. But with a new laptop, I’m being very conscious (and proactive) about finding good workflows.

I think I’m going to take a long look at KM to see where that can take me first.

2 Likes

I have Launchbar which is similar to Alfred I believe. It is a wonderful app and I will continue to use it. I could manage just with Keyboard Maestro now though for sure. I like to have both really.

I recently listened to MPU ep 497 and also the follow up about Alfred. I never looked at Launchbar until the other day albeit very quickly. I figured there was very little need since I had Alfred. But the question became whether I should take a look at Launchbar. I don’t like switching apps to the latest and greatest.

One thing that I know I want to learn and utilize is a clipboard manager. I don’t know why I’ve never dug into one.

Yeah. I only have Launchbar, that was the one I started with. I have been tempted to try Alfred, folk say good things about it. Actually I am spoilt for choice. Launchbar’s clipboard manager is excellent and I use it. I also though use the clipboard on Keyboard Maestro, which is, for my uses anyway, slightly better and has a larger capacity and you can ‘fix’ favorites. It is really worth exploiring. That is one reason I could manage now just with Keyboard Maestro. I only found the clipboard recently too. These powerful apps have resources you only discover after months or years.

If anyone is considering migrating to Keyboard Maestro for text expansion, I post below an AppleScript that I threw together to rapidly create KM macros for this purpose.

At the top a variable named snippets is set to a list of the snippets to create. For each line, set sName to the name to be given to the macro; set sString to the string to be inserted when the macro is run (the macros are created using the insert by pasting [faster than insert by typing] and auto delete the trigger characters); set sTrigger to the snippet trigger. You can add as many lines to snippets as yo like.

Below that, set targetMacroGroupName to the name of the macro group to put all of these snippets into. If this group does not exist, it will be created.

I like the idea from @JohnAtl to have a pop up palette with triggers in it, so you can set paletteMacroGroupName to the name of a macro group used for the pop up palette. Again, this does not exist it will be created. HOWEVER, you will need to manually edit the created group to set it up as a palette and format the palette’s appearance. [There is some commented xml to do this (and set it up with the theme I want for the snippets palettes, but I haven’t testing that part yet, so it is commented out for now. Feel free to test and let me know what corrections are needed.] If you want to populate these snippets into the palette, also set makePaletteEntry to true; if false then no palette population will be made. Also, the palette group won’t get automatically created if this is false.

If you want to prefix all the created macros with a string, set it as macroNamePrefix. If you want all of the triggers to have a prefix (here I use “;;”) set that as macroTriggerPrefix. Note that you should NOT include the prefix in the macro trigger in the snippets variable. if it is specified here.

Hope this proves useful to someone. Happy to make (limited) modifications if anyone has any ideas to enhance this script.

set snippets to {¬
	{sName:"", sString:"", sTrigger:""} ¬
}

set targetMacroGroupName to "Snippets: General"
set paletteMacroGroupName to "Snippets Palette"
set macroNamePrefix to "General: "
set macroTriggerPrefix to ";;"

set makePaletteEntry to true

tell application "Keyboard Maestro"
	
	set mgs to every macro group
	repeat with mg in mgs
		if the name of mg is targetMacroGroupName then
			set targetMG to mg
		end if
		if the name of mg is paletteMacroGroupName then
			set paletteMG to mg
		end if
	end repeat
	
	if targetMG is equal to missing value then
		set targetMG to make new macro group with properties {name:targetMacroGroupName}
	end if
	if makePaletteEntry is true and paletteMG is equal to missing value then
		set paletteMG to make new macro group with properties {name:paletteMacroGroupName}
		(**
		xml:"<dict>
									<key>Activate</key>
									<string>OnceWithPalette</string>
									<key>AddToMacroPalette</key>
									<false/>
									<key>AddToStatusMenu</key>
									<false/>
									<key>PaletteUnderMouse</key>
									<false/>
									<key>Targeting</key>
									<dict>
									<key>Targeting</key>
									<string>All</string>
									<key>TargetingApps</key>
									<array/>
									</dict>
									<key>Theme</key>
									<dict>
										<key>Columns</key>
										<integer>3</integer>
										<key>Size</key>
										<integer>19</integer>
										<key>Theme</key>
										<string>Evening</string>
										<key>UseDefaultInstead</key>
										<false/>
										<key>UseIcon</key>
										<false/>
										<key>UseTrigger</key>
										<true/>
									</dict>
								</dict>"}
								**)
		
	end if
	
	repeat with snip in snippets
		set {sName, sString, sTrigger} to {snip's sName, snip's sString, snip's sTrigger}
		
		tell targetMG
			set m to make new macro with properties {name:macroNamePrefix & sName}
			tell m to make new trigger with properties {xml:"<dict>
						<key>MacroTriggerType</key>
						<string>TypedString</string>
						<key>SimulateDeletes</key>
						<true/>
						<key>TypedString</key>
						<string>" & macroTriggerPrefix & sTrigger & "</string>
					</dict>"}
			tell m to make new action with properties {xml:"<dict>
						<key>Action</key>
						<string>ByPasting</string>
						<key>MacroActionType</key>
						<string>InsertText</string>
						<key>Text</key>
						<string>" & sString & "</string>
					</dict>"}
		end tell
		
		if makePaletteEntry then
			tell paletteMG
				set p to make new macro with properties {name:macroNamePrefix & sName}
				--tell p to make new trigger with properties {xml:"<dict>"}
				tell p to make new action with properties {xml:"<dict>
						<key>MacroActionType</key>
						<string>ExecuteMacro</string>
						<key>MacroUID</key>
						<string>" & m's id & "</string>
						<key>TimeOutAbortsMacro</key>
						<true/>
						<key>UseParameter</key>
						<false/>
					</dict>"}
			end tell
		end if
		
	end repeat
	
end tell