How to Trigger KM Macros from LaunchBar

I have just discovered (I'm probably really late to this game) that one can create Launchbar actions which trigger specific KM macros or invoke palettes of KM macros.

For example, I created a LB action called "URL Preview" which triggers a KM macro (which I posted about here) which pops up a web browser window using the URL in the clipboard.

Basically, I made the LB action execute a simple Applescript:

And ... boom!

To make it simpler:

Using the trigger URL of your KM macro you can create a Search Template in LaunchBar.
For example:


This has the nice side effect that you can pass along a value to the macro.

(Hit ⇧Return to omit the value query; the previous value will be used then.)

I am gobsmacked. I will use this. I would still need to create specific actions for some macros, because I have a number of macros which have the same name, but are distributed in different app-specific palettes.

OK, when I trigger this with a macro name as the value, I just get the Trigger By Name dialog with nothing in the query.

No, the value is not there to trigger a specific macro. It’s the macro UUID you see in the template that triggers the corresponding macro with that UUID.

The value is what gets passed to that macro. It can be used by the macro itself. The value (from the LB search template) will end up in the %TriggerValue% token of the launched macro.

In my example I used the value to set different options for the "Trigger Macro by Name" action:

Trigger Macro by Name(For LaunchBar).kmmacros (2.4 KB)

Hope it is clearer now :wink:

BTW, it seems you can’t use the %TriggerValue% token in the Search field of the above macro. It will not get expanded. Variables either.

I guess, my example is a bit confusing. A more "normal" use-case for passing a value would be, for example, to pass a number to a calculation macro.

###Edit / PS:

Here is a more straightforward example how to make use of the value from the LaunchBar search template:

Create a Search Template in LaunchBar with this content:


Install this macro in KM…

Example: Working with a Value from LaunchBar.kmmacros (1.6 KB)

… and then launch the Search template in LaunchBar. The string you enter will be spoken by the macro.


Tom, please remind us with low memory how to launch this Search template in LB. (I know, you’ve probably told me a hundred times. :wink: )

You launch it as you launch anything in LB: by typing the fuzzy character sequence that leads you to your action. Initials serve best.

For example, if you have named your serch template “Speak Something via KM” then it should be sufficient to type “ssk”. If not on top of the results, it should be near the top of the results.

Unless you have already 30 other actions that respond to the same initials :wink: Then it might take two rounds of training for LB.

1 Like

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*

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

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.


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:


  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?


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.


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:


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