Calling Keyboard Maestro Macro from a Chrome Extension (javascript)


I would like to be able to right mouse click in Chrome to launch a chrome extension (written in Javascript) that calls a Keyboard Maestro Macro. What javascript command do I use from my background.js file?


You can use the URL form:


You should be able to open that URL from within your .js, or just link to it.

The code is the UUID of the macro, which you can get view Edit ➤ Copy as UUID.

1 Like

Hi Peter,

That helps thanks.

However, using the URL Form seems to open a new a browser page at
kmtrigger://macro=F22DEE05-B682-478C-8F0A-C22494FD730D which then executes
my macro and in my macro the first command is to Copy (i.e., simulate
cntl-c to save the selected text to a variable) and Open a new URL to fill
in a form but because of the order of things, the Copy is not copying the
selected text in the original browser tag. Is there another form (not URL
Form) that just calls the KM Macro?

That is, can I call something in my background.js file that triggers the
Macro but doesnt create a chrome window like the code below does?

function itemOnClick(info, tab) {{“url”:
“kmtrigger://macro=F22DEE05-B682-478C-8F0A-C22494FD730D” });


I don’t know I’m afraid. Maybe there are other ways of opening the URL, or maybe you can execute AppleScript somehow. I don’t have any idea what options Chrome or JavaScript has for this.

Hi Peter, This is the same issue that I have contacted you about. Did Andrew find a solution to this?

I need to call the KM Macro from within a Javascript .js file?

I still don’t know I’m afraid.

Generally JavaScript in the browser is relatively locked down. Browser authors do not want your web pages to be able to execute arbitrary code on your Mac, that would be a huge security hole.

So unless the browser has a specific security hole you can actively create (ie, explicitly specify some action or page as allowed to perform some specific task, breaking out of the containment of the web browser sandbox), it will not want you to be able to trigger a macro by any means.