Activating a Keyboard Maestro macro in Alfred

I’m an Alfred newbie.

What’s the simplest way to launch a specific KM Macro in Alfred?

Thanks in advance.

I did try to simply launch a kmtigger URL but nothing happened. Here’s my setup:

Any advice?

I don’t know if it’s the easiest way, but I call a Keyboard Maestro macro from an Alfred workflow using Applescript. If you use the Alfred Run Script action using the language osascript, the macro by name can be run using:

tell application "Keyboard Maestro Engine"
make new variable with properties {name:"AlfredVarName", value:"{query}"}
do script "Sample Macro Name"
end tell

I’ve included a line I use to save the Alfred query output as a KM variable, which is handy.

1 Like

I’ve used this workflow previously from Thought Asylum - might be worth checking out: An Update to the Conductor Workflow | ThoughtAsylum

2 Likes

I use exactly the approach used in your second post in my Alfred workflow that @rymawby referenced.

I created a simple Keyboard Maestro macro called “Open_Calendar” as per your named macro above.

I then created the equivalent workflow:

When I enter “Test” into Alfred and run the workflow, I get a pop up on screen. That set up works for me.

My best guess would be that if you are able to run the Alfred workflow and nothing happens, then the most likely culprit is that your Keyboard Maestro macro name is not “Open_Calendar”.

After that, it might be an issue with your macro. I assume it runs fine outside of Alfred, but it may be worth a double check.

If none of that yields anything, look in the Keyboard Maestro logs. In Keyboard Maestro, open the Help menu and select Open Logs Folder, then have a dig around in Engine.log file). Keyboard Maestro has really great logging, and you’ll be able to see what it is up to.

Hope that helps.

2 Likes

Thank you for the replies. I figured out the problem. The macro was within a KM folder that was only authorized to run within OmniFocus. Once I removed that prohibition the macro launched from Alfred.