Pass alfred's keyword as a variable to KM

I hope to achieve this effect:
Open and insert the keyword "hello world" entered by alfred.

But it doesn't seem to work. What should I do?

Thank you very much!


As always, there are several ways to solve issue's. And It's up to you to choose, based, on pros/cons && skill, and preference's.

Not sure what kind of keywords you want to pass. Using a file a a intermediate between processes is often not the best solution (in an async world). But with the right checks ((own made) semaphores) that can be done. And preferable if the 'keywords' is a big bunch of (changing) data.

But other wise you've got two other options aswell:

  1. Set Keyboard Maestro variable (on or more) Keyboard Maestro Variables and Scriptingwith (java)script from with in Alfred before triggering Keyboard Maestro
  2. Use a parameter in with a trigger: kmtrigger://macro=F9E19E5D-CB34-423C-AA67-827B1F657665&value=Whatever and use the %TriggerValue% to get that value [token:TriggerValue [Keyboard Maestro Wiki]](https://More about the triggervalue).

Hope this helps. Let me know.

1 Like

Thank you for your kind reply.
I want to pass a variable of type text.
My English is not very good. I think I used the first method you said, which is to use scripts in aflred.
It doesn't work.

It is hoped that the passing variable can be implemented.
So alfred is an input interface, and then more functions can be realized with KM (I can't write code, KM is relatively simpler for me)

Hi @live,

In the following macro

The Timer with Alfred may give you some idea on how to pass Alfred argument as KM parameter.

1 Like


Thank you very much! The problem solved
Your method is perfect! I can modify it even if I can't program.

To facilitate people with the same problem to understand the principle, I simplified your script.

It works like this:

You can also download your own editing.
Pass Variable To (62.1 KB)