Passing filenames from LaunchBar to KM-Macro

Alfred or LaunchBar are great tools. Keyboard Maestro more :wink:

I have a problem and can’t find a solution: i want to pass one or more file(s) (or filename(s)) found by Alfred- or LaunchBar-Searches directly to a Keypass-Macro.

Example: i have a lot of log files for my clients. Every log file is placed in a client-specific folder. Every time i contact the client (Meeting, Phone), i jot down notes into the client-specific log files. The log files are simple textfiles.

What i want to do is to search for the file with LaunchBar by client-name and pass the file or filename to a Keyboard Maestro Macro, which opens the file in TextEdit and writes current date and time in the first line ending with two „Return“-keystrokes. After this i simply jot down my thoughts…

My Problem ist to get the filename given by LaunchBar in Keyboard Maestro. Is there a specific variable or a text token for this case? Or any suggestions for another way to do this?

Thanks a lot,


I presume Alfred / LaunchBar can execute a script and pass the file name as a parameter.

Presuming this, write a script that reads its parameter, then sets a variable to the parameter’s result, and then executes a macro. This is most easily done with an AppleScript scpt, something like this:


on run argv
	set arg to item 1 of argv
	tell app "Keyboard Maestro Engine"
		  make variable with properties {name:"Input Parameter", value:arg}
		  do script "Process Parameter"
	end tell
end run

Cool! Thank you Peter. With a little help from i created this:

on handle_string(theString)
   tell application "Keyboard Maestro Engine"
	make variable with properties {name:"Input Parameter", value:theString}
	do script "Process Parameter"
   end tell
end handle_string

And it works! Thanks again!


Would you mind sharing the macro as I think it could be something I could use.


\ Jimmy Hartington

Hi Jimmy,

of course... But there is no magic :wink:

Hi again

Ok. Seems simple.

What are you workflow or steps when using Launchbar to pick up the file
and execute the applescript.

snapitup wrote:

(Also late to this thread, but the thread is current.)

Selecting a text file with LaunchBar and sending it to Keyboard Maestro in order to open it in a text editor and have text prepended seems inefficient (imho). Why not just open the file in your text editor and run a KM macro that prepends the text? Yes, this is two separate (but easy) user actions, but it is

  • simple
  • follows the standard process of executing KM macros from within applications, and
  • allows you to insert your dividing text on open files (perhaps usable if you time-stamp your entries).


  1. Search, find, and open file in associated program (LaunchBar, initiated by hot-key)
  2. Insert text (including blank lines) at top of text file and position insertion cursor for user input (KM, executed by trigger {and look into a typed-string trigger for this})