Can an HTML Prompt use kmtrigger?

I'd like to have an HTML Prompt onscreen, with some clickable links in it. Those links are kmtrigger URLs, to launch other macros. This can't be a "click and done" thing, so the click can't dismiss the prompt, so I can't use next steps in the current macro to do anything, because it's still "stuck" on the prompt.

I've got the structure of the URL correct (they work in a browser), but they don't do anything when clicked inside the Custom HTML Prompt. I assume this is related to prompts being a "blocking" activity, but don't know exactly what, nor do I know how to work around it.

I thought maybe running the prompt asynchronously would help, but I had the same results doing that. Then I thought maybe I could launch an asynrchronous macro just before I display the prompt…but I don't know what that macro could do, because it has to get the click info out of the prompt.

Is this feasible at all, or do I need to take another approach?

-rob.

Which macOS app are you expecting to "open and process" the link?

I apologize for asking a question to such an esteemed person as yourself.

1 Like

It's the kmtrigger:// URL scheme with a macro UUID in it; it should launch the macro (which is what happens with the URL in a browser.)

-rob.

Oh wait, I wonder if I have to use the data-kmhandleschemes bit ... thanks for getting me thinking! Off to experiment.

-rob.

Yes, but the browser is running code to take the action. I'm not sure what you are expecting to be taking the action in this case.

My Macro Reporter Macro udd kmtrigger to launch macros listed in an HTML prompt. The prompt is not asynchronous.

But the trick is matching the macro with the current application. If it isn't supposed to run, it won't.

1 Like

The HTML prompt uses WebKit to display the HTML, so I figured it would be aware of the URL scheme. Apparently that wasn't correct. Adding the data-kmhandleschemes didn't help.

I'm not sure I understand that restriction? The macro is in a group that runs in my browsers, and the macro I'm triggering (as a test) is in that same group, and just displays "Hello world." But I get nothing.

I looked at your macro (which I've had sitting here and use, just never thought to look at it :), and your use doesn't look much different than mine—you're using JS to build the link, and I'm building HTML on the fly for table rows, but my syntax is the same as yours.

Weird.

-rob.

OMG, whatever many hours later, and as I solved the problem I realized you gave me the answer—I just couldn't parse it at the time.

I was testing my macro in the editor, but it's in a group that runs in browsers. That works fine for testing, until you tell it to launch another macro that's in the same restricted group: It fails to launch because the right app isn't frontmost.

Dang that was a frustrating trip down self-stupidity lane!

EDIT: And in the end, I didn't use kmtrigger, I used window.KeyboardMaestro.Trigger, but was having the same issue with that for the above reason.

-rob.

2 Likes

That's how I got there too!

1 Like

It's a very well-travelled road...

2 Likes