How to Trigger KM Macros from LaunchBar

Thanks, Tom. I had just figured it out, but your post is better, and reminded me to use the initials (first letter) of each word in the LB search name.

So, here’s my small contribution to using LB, which I probably got from @Tom somewhere else:

KM Wiki Search
https://wiki.keyboardmaestro.com/Home_Page?do=search&id=*

which you can easily trigger in a LB prompt by using:
kws

1 Like

LaunchBar is excellent. If your typed string doesn’t bring your desired target to the top, scroll down and select it (and run it — just double-click or after selecting type {return}). LaunchBar will “learn” your preference over time. If you’re impatient and disciplined enough to use the same typed string, it’s 20-seconds work to assign a string to a target.

It does what it does really well.

1 Like

Yes, initials are often recognized instantly when you have created a new action. But basically any fuzzy abbreviation —somehow related to the name— will do. You just might have to "insist" 1, 2 or at most 3 times, and then LB will have gotten it.

With "insist" I mean: typing the fuzzy abbreviation (e.g. in the above case "spso" instead of the "ssk" initials) > LB will not list the action at the top > you select it manually from the list.

I often change my abbreviations this way, especially when I add new actions with a similar name, or when my brain insists in memorizing something different from what I had planned :wink:

The flexibility of those abbreviations is one of the reasons I love to work with LB. Even if I forgot how exactly I named my action 3 months ago, and I type a vaguely resembling abbreviation, chances are good that the action will be found. Not at position 1, but it’s in the first 10 or 15 or so.

Trying this with a fixed modifier-hotkey-based system will make you cry and die in madness…


BTW, over at the LB forum I posted some tips about reasonable LB usage, in the context of memory/energy consumption and Index size.

2 Likes

Good point. That allows us to assign a specific text shortcut to a KM Macro or other action.

1 Like

O you made me look it up, just for completeness sake :wink:.

After typing string in LaunchBar, “{Right-click target} ▹ Assign Abbreviation”.

For some reason my experience differs from Tom’s — my fuzzy abbreviation bring up faggots of chaff and rarely a kernel (it is likely I am having LaunchBar index too many items). I assign abbreviation wantonly … and remember them. YMMV.

1 Like

That’s weird.

I just played it through with the mini example from above (search template “Speak Something via KM”):

  1. I launched it a dozen times with the ssk abbreviation (Speak Something via KM) to make sure LB has deeply learned it.
  2. Then I tried it with spso (Speak Something via KM)
  • On position #1 on the first try
  1. Now with sst (Speak Some‌thing via KM)
  • 1st try: position #2 → Selected it manually from the list → 2nd try: position #1
  1. Now with ss (Speak Something via KM)
  • 1st try: position #3 → Selected it manually → 2nd try: position #2 → Selected it manually → 3rd try: position #1
  1. Now with km (Speak Something via KM)
  • 1st try: #4 → Selected it manually → 2nd try: #1
  1. Now with thing (Speak Some‌thing via KM)
  • 1st try: #14 → Selected it manually → 2nd try: #1

Of course, the exact behavior depends heavily on the names of your other actions, search templates, files and indexed items in general.

And —as you have said— the total amount of indexed items will play a hefty role: each item in your index is competing for top position when you type an abbreviation. So, for example, if you have a plethora of indexed files/folders with a similar name, it will take some more training rounds to filter out the rubbish and get the desired result.

So: Get rid of anything in your index that you don’t use somewhat regularly. (To find the last file in the last corner of your disk use Spotlight or EasyFind.) Besides making your abbreviations more efficient LB will thank it to you also by consuming less memory and energy.

If you start doing that on large scale you’re giving away one of the best features of LB, it’s capability to learn. What a pity! :sob:

IMO, assigning fix abbreviations makes sense in some edge cases where the abbreviation really has nothing in common with the actual name of the action. For example if you would insist to use the abbreviation 123 to launch the “Speak Something via KM” search template.

1 Like

FYI: I posted in detail about creating LB actions to trigger specific KM macros or palettes, here.

1 Like

Apologies for hijacking this old thread.

I am currently venturing into launchbar and am also looking for an easy way to access KM macros from launchbar. Something that could preferably add KM macros to the main index so you can assign a abbreviation to it.

I am currently using the Action linked in the first post and it’s working great. I can do km <macro name> and it executes it, but I can’t assign a abbreviation to the subsearch. I want in the best way possible just do <mcn>.

See my reply right above yours with link.

Here an up-to-date example (with KM9’s new OCR) to demonstrate how wonderfully LaunchBar’s Search Templates work for launching KM macros with (or also without) a trigger value:

The OCR macro

Very simple:


OCR Screen Shot.kmmacros (4.1 KB)

It copies the selected screen area to the clipboard and passes it to one of KM9’s OCR actions. The OCR’ed text will be saved to the clipboard.

The trigger value (see below) decides which OCR language will be used.

The LaunchBar launcher

As launcher we use a simple Search Template in LaunchBar:

The URL is the kmtrigger URL plus an added trigger value at the end in the form of &value=*

You get the correct kmtrigger URL for the macro from the popup menu in the macro header:

Usage

  1. Select the Search Template in LaunchBar and press Return or Space.
  2. In the next field enter your desired OCR language (“d”: German, “e”: Spanish, “f”: French, nothing: English) and press Return again.

That’s it.

1 Like

Tom, your LB setup to trigger the KM OCR looks very interesting.
When you have time, would you might explaining how to install this in LB?

Thanks.

Hm, I think it’s all explained. Search Templates are an integrated feature of LaunchBar, nothing to install (they are normally used for search engine searches and such). See also the linked post where I first mentioned Search Templates as KM macro launchers.

If it’s still unclear, feel free to ask.


Edit:

Ah, in case you are asking because of the “KM Macros” group (in the LB side bar):

I created it to not mix my KM launchers into the “regular” web search templates. You can create a new group of Search Templates with the “Plus” button:

56-pty-fs8

But this is optional. You can also add your KM launchers to your other Search Templates.