Execute a macro via a link in Evernote

Sounds like a great idea.

I've never used, or even explored, the KM Web Server.
Another whole world . . . :smile:

1 Like

I just now used it for the first time, because I thought it might be a solution. :slight_smile:

I can see one issue right away - it opens a browser window. So Iā€™m guessing this isnā€™t ideal. But my mind is whirling, trying to imagine a way around that. Iā€™ll let it simmer and see if anything comes to the surface.

For instance, the macro could close the browser window (tab).

Or perhaps something else.

1 Like

How do you handle macroname when the macro name has spaces in it? thanks very much

%20 instead of name. Or use ā€œCopy as UUIDā€ and use that instead.

1 Like

I am very sorry Don, I still donā€™t understand.
Letā€™s say that my macro name is as below
open XYZ restaurant menu
note that the macro name includes spaces
how would you write:
kmtrigger://macro=MacroName&value=Value
If I understand correctly, I can ignore &value=Value if I do not want to pass a value, but how do I write
kmtrigger://macro=MacroName
if the macro is named as above
Sorry once again for taking your time, and thanks

I already answered that above:

1 Like

NOW ! I understand. Thanks so much!

A post was split to a new topic: How Do I View PDFs and Take Notes with Evernote?

what does UUID mean?
thank you

It means something like ā€œUniversal Unique Identifierā€, at generally looks something like this:

05AD9384-E8F1-479C-A6C0-209CE7A963DA

Itā€™s guaranteed to be unique across all devices in the world (thereā€™s a couple of exceptions to this, but for all intents and purposes, it really is).

KM uses the UUID internally to identify Groups and Macros. Thatā€™s why you can have macros or groups with the same name - to KM, theyā€™re different because they have different UUIDs.

For Keyboard Maestro macros, you can get the UUID by using Edit->Copy->Copy as UUID.

So if you ever use something like the ā€œkmtrigger://ā€ feature, itā€™s best to specify the macro UUID rather than the macro name. This way thereā€™s no problems with duplicate names, and if you ever rename the macro, it wonā€™t break anything.

Probably more info that you wanted, but there you have it,

1 Like

crystal clear. thank you very much

@DanThomas, you are the man! :grinning:
I would never have figured out how to do this without your post.

@peternlewis, the KM Wiki article on "Web Server" is woefully lacking.

  • It does NOT provide any of the commands (like "action.html"). Are their others?
  • I would update, but I don't know enough.

I just implemented this, and it works great!! :thumbsup:

Here's my new macro, that has NOT had much testing or use yet, so if anyone wants to use it, you do so at your own risk.

##Macro Library   @Web Open URL Passed from KM Web Server


####DOWNLOAD:
<a class="attachment" href="/uploads/default/original/2X/f/f1e227dc9a4a0f70c16d14977adf13acadff5570.kmmacros">@Web Open URL Passed from KM Web Server.kmmacros</a> (4.5 KB)

---

###ReleaseNotes
**āš ļø  Warning!  This uses the KM Public Web Entry, which may have some security issues.  See [KM wiki for details](https://wiki.keyboardmaestro.com/trigger/Public_Web).**

The KM Web URL is like this:
`http://127.0.0.1:4490/action.html?macro=<YourMacroUUID>&value=<TheURLYouWantToOpen>`

For example:
```html
http://127.0.0.1:4490/action.html?macro=1238B406-69B6-4093-8E59-85431F7483AD&value=/Users/Shared/Dropbox/Your%20File%20Name.txt
```
---

<img src="/uploads/default/original/2X/a/a67e1e440d917a4d4768e1d59d7af59e555a3840.png" width="583" height="911">
1 Like

The article does look very light on useful information.

The commands are not documented because they are not an API, and entirely subject to change.

People are welcome to use them, but documenting them on the wiki would be like documenting the XML of the Keyboard Maestro Macros - it would imply that they are a valid API and enforce backward compatibility requirements that I donā€™t commit to.

Using them on the forum on the other hand is perfectly fine, since it does not put a requirement never to change it on me.

As for how you figure out the URLs, its the same as any web site, you can see the URLs used in the links or address bar of the web server or by looking at the HTML.

Peter, as you say, the wiki provides little info an using the KM Public Web URL.
Could you please expand when you get a few moments?
We just had another question about this.

trigger:Public Web [Keyboard Maestro Wiki]

I would do it myself, but I don't have enough info to do so.

Thanks.

Can macros return a custom response after executing?

Of course. As the last Action of your macro, you can do a number of things:

  • Display a custom msg based on the macro results
  • Copy same to the clipboard
  • Display a notification
  • Send an email

What did you have in mind? The more details you provide us of your desired workflow to automate, the better we can make suggestions.

@JMichaelTX, thanks for the response!
Can a macro directly return a response to the http request?
The client would run a macro over http request, and get a result in form
of http response at the same time.
Then I can just return response data in json string.
Thinking about writing an iOS app, and this would be amazing!

I don't know. So I suppose you're wanting KM to behave like a web server, right?

It would seem that the primary purpose of the KM Web_Server trigger (KM Wiki) is to execute a KM Macro, which in general don't behave as a web server would. But I'm just guessing.

Perhaps @peternlewis can jump in here and clarify.

Why not just build a real web service? Since KM Variables are available through scripting, the web server could trigger a KM Macro, get the results in a KM variable, and return that to the caller of the web service. Just thinking out loud here.

@JMichaelTX, thanks again. Thatā€™s correct.
It would be complicated to package a web server and distribute.
It would be much simpler if KM supported this out of the box.
@peternlewis, any thoughts?
Thanks!

No, you cannot get a response from the macro through the web server.

The macro could send a response to another server, so potentially you could send a response back that way.

But you cannot simply hit a URL on the Keyboard Maestro web server and get any kind of response back other than ā€œOK, I triggered the macroā€.