Can %Trigger Value% value contain a slash?

I want to pass a URL as Trigger Valve,but I found that I can’t because it contains a slash.

Welcome to the forum. There will be an easy solution (maybe even just putting the URL in quotation marks) but can you tell us more about how you are using the URL in a trigger?

It might help if we could see your macro, or at least the relevant part of it. Please see Getting Started with Keyboard Maestro and the Forum for tips.

kmtrigger://macro=220DDC5F-3712-4208-BC31-E02D32BEEF89&value=https://dida365.com/webapp/#p/67a30c496407510b354c6e4f/tasks/67c983241f585181ffecda0a
I want to pass the variable to the “open URL” action.

i have put on a picture

It's not that you are passing it as a KM trigger value, but that you are trying to use it in a URL parameter where it isn't an allowed character. So you'll need to "URL Encode" each / as %2F.

How you do that will depend on what you are doing because % is a special character in KM. It'll be easier to help if you post your macro -- see How to Post/Upload your Macros and Scripts for how to do that.

1 Like

KM will ignore a kmtrigger if an unencoded URL is used as the value that is to be passed.

So this will not be usable:

kmtrigger://macro=example&value=https://example.com

but this will:

kmtrigger://macro=example&value=https%3A%2F%2Fexample%2Ecom

I tested that with this example macro. It works, despite the orange warning colour of the text in "Open URL"...

Using a variable as a go-between gets rid of that orange...

This macro opens example.com, which was passed in as the value, and also keyboardmaestro.com.

But how useful is that? @yjc_aaa, what do you aim to do by passing a URL in a kmtrigger and then opening that URL? If you tell us more, someone may be able to help you with your underlying aim.

1 Like

I'm not so sure...

I can't tell if "Open URL" action silently fails (ie does nothing but the last action result is "OK") when the text field contains (or resolves to) a malformed URL; if the action works but the OS-level "open location" thingamajig refuses the malformed URL, or if the Engine receives the URL but ignores it.

This simple macro:

...will be executed by any of:

image

...but nothing happens with

image

If it just ignored the bogus parameter and processed the rest then the macro would run.

Whatever actually happens the end result is the same -- no execution.

What might be important here is what the kmtrigger:// is being sent from. I've a feeling that it would be easier to call a parametered macro using the "Execute a Macro" action if this is part of a KM macro...

In particular, it's the slash that causes KM not to deal with a raw URL.

Quite so, and I think your tests confirm my observation that the encoding must be handled in the kmtrigger URL, not just in a filter action before an Open URL action.

I must presume that KM is designed to disregard such invalid triggers, as it would any invalid trigger.

https://wiki.keyboardmaestro.com/trigger/URL does not mention slashes, but it directs "Do not include the "%value=" without a value." (I think that should be "&value=" – one for @peternlewis if so :slight_smile: ). In fact, missing out the value doesn't appear to cause problems in my limited testing with KM V. 11.0.3.

Edit: a reminder that the salient issue is why one would want to pass in a URL via a kmtrigger in this way, especially in this particular instance.

Thanks! I actually don’t know much, haha. I want to paste TickTick task links into other apps and open them via Keyboard Maestro’s URL action (so that TickTick opens the link instead of the browser, which is the default for other apps). Currently, TickTick doesn’t have a dedicated URL scheme for jumping back to the app—its provided links only work internally. But I accidentally discovered that opening the link with TickTick itself allows the jump!

I have another question. Have you used OneNote before? How can I convert such a link into OneNote’s link format so that when I paste it, it is already a clickable link? It seems that the clipboard uses an HTML format or something like that. I’m using OneNote in a virtual machine on Mac, and I’m wondering if I can use Keyboard Maestro to process the clipboard.

I think I follow that. ticktick.com says:

"Each of your tasks has a unique link. Simply copy the link of task A (from the “…” menu) + paste it into the description of task B. These two tasks will be connected. You’re then free to jump from one to another anytime you want."

It appears from your post that you want to be able to embed task links into documents that other applications use; however, you say that Ticktick does not have its own URL scheme, so your idea is to open the task links by using an open URL action in a KM macro.

If I have understood the situation correctly there, I think that you need to do something like this:

  1. Use an open URL action to open the Ticktick URL, so that Ticktick opens that task. First try triggering your macro in a simple way, such as a hotkey, to see if that will work. If this step does not work, we will not need to move step 2. :wink:

  2. If that does work, set up a good way to trigger the macro from the document that contains your tasks... and I understand now why you wanted to use kmtrigger!

You gave the example
https://dida365.com/webapp/#p/67a30c496407510b354c6e4f/tasks/67c983241f585181ffecda0a

If https://dida365.com/webapp/#p/67a30c496407510b354c6e4f/tasks/ is always the same for every task, and the last part, 67c983241f585181ffecda0a, is unique to one particular task, you would not need to pass the whole string to Keyboard Maestro. You would only need to pass the unique part, e.g. 67c983241f585181ffecda0a:

Your macro could:

  1. set a variable to %TriggerValue%. Let's call the variable "local task".

  1. use the open URL action to open https://dida365.com/webapp/#p/67a30c496407510b354c6e4f/tasks/%Variable%local task%

In summary: you might like to see if you can meet your goal by passing in as short a string as possible, leaving out the site URL (these task links really do all go via a public site?).

I hope that gives some ideas.

Yes indeed. The system clipboard's contents can be accessed using the token %SystemClipboard%.

Yup. You’ll want to use keyboard maestros filter action to url encode the first url and append the keyboard maestro macro trigger to it.

Have the macro decode the URL trigger value and do its thing to open :white_check_mark: :white_check_mark:.

Then paste that URL somewhere.