Unable to Use Variable as Either Clickable Link or in Open URL Action

Hello,

I managed the feat of having 2 errors in a 2 action macro.

I often use URLs followed by many uses of that URL throughout a macro, so I had the idea of entering the URL only once at the beginning of the macro and creating a variable instead of typing in the URL multiple times within the macro.
I created a simple example below.

My problems are that:

  1. The display window does not show a clickable functional url.
  2. The open url action generates an invalid url error message.

Thanks very much for your help and patience.

The macro is uploaded
:heart: :hammer_and_wrench: Test Variable for URL.kmmacros|attachment (3.0 KB)

The error message stated that the URL "%Variable..." was not a valid URL. That's a big clue. Because it contained the token "%Variable..." that suggests that the token wasn't being processed. And sure enough, I looked at the flags on your Open URL action, and you turned off the Processing of Tokens. Open the action's cogwheel and turn token processing back on.

That was the solution for your problem #2. As for #1, I didn't know/think KM was supposed to put clickable links in Display actions. So I'm not smart enough to help you with that one. (And I'm getting tired.)

1 Like

thanks very much for the 1st question

Yes, clickable links are allowed in display actions. I use them for reminders on a daily basis.

I'm almost asleep. Maybe someone else will help you with your other problem.

1 Like

thanks very much. Buena Notte !

Try this one @ronald,
:heart: :hammer_and_wrench: Test Variable for URL_fix.kmmacros|attachment (3.1 KB)

1 Like

What is this magic? I can see that it works, but I've spent 15 minutes trying to understand why, and I don't understand it. I truly enjoy being stumped, but you've put me through enough pain.

1 Like

sorry and very funny video

Have you figured out why his solution works? I think I may be onto it now. But it's still blowing my mind.

No, because it goes against what the excellent @Zabobon taught me about variables which is to always use the prefix %Variable%

But it's more complicated.
The example I gave was with safari which works fine.
If I substitute a Scrivener link, the display window link no longer works, although it works fine if I just copy paste the Scrivener link itself.

thank VERY much for your interest.

Funny thing: I didn't notice THAT difference. But I don't think that's the reason it works. I think the reason is based on the fact that the text in that box is not plain text, but Rich Text. There's a difference, because Rich Text can contain "invisible web links." He converted his text into a web link. But that doesn't explain why it used to work for you, but doesn't anymore.

As soon as I completely understand how to add and remove web links, I'll let you know here.

HINT: You can even click on the link in the action in KM. You don't need to run the macro to see this effect.

ADVANCEMENT: I can now accomplish the same result as KC did, but I'm pretty sure this is not HOW he did it because my method is very ugly. But I'm still working on it.

TIP: If you want another hint into how he did it, just select all the text in his action, right click on it, and then click on "Edit Link." In your action, this doesn't work. Getting your action to work the same way is what I'm working on. I've got a method but my method is definitely not the "right way," so I'm still working on it.

ADVANCEMENT: I found a way to make his link fail, which may give me some insight into how to making yours succeed.

1 Like

thank you. I think that your level of skills is way above mine.

@Sleepy and @ronald ,

I didn’t do any trickery or magic. I also didn’t do what @Sleepy said I did (I didn’t convert the link).

@ronald - you asked a similar question that @peternlewis answered.

See here:

What I did was typed the full link to test and then I deleted the link and replaced the link with the variable. KM recognized the variable as a URL. I tested again, it worked and I posted. I actually tested different links in the set variable action. I can’t make it more complex than that. Sorry to disappoint you. Peter said he would make the link detectable in that upcoming version. @ronald , if it works, please mark the solution so we can fight with another problem. :grinning:

KC

1 Like

thank you @kcwhat

1 Like

I would like to ask what you mean by "I deleted the link" because when I delete the link, KM does not recognize the variable as a URL. Maybe it's because I deleted it differently from the way you deleted it. I simply used backspace to delete. What did you use? It still feels like magic to me, because I can't replicate it based on your explanation.

I selected the URL that I initially used to test (I.e. https//talk.automators.com) within the Display Text window and then hit my magic backspace key and typed the variable. Maybe my system is different. I swear I didn’t spend a whole two minutes, from start to post, because I had to deal with an Apple HIIT workout that I didn’t want to do.

If you want me to make a video, I can do it when I get home. Just let me know.

KC

Hehe, I'm glad we both see the humor in all this. I enjoy challenges and I will keep working on this. But I think the underlying cause here is that sometimes KM treats text boxes as plaintext, but sometimes it treats them as richtext.

One curious side effect of this duality is that if you take your Display action which works, then change the option that says "Display Text in a window" to "Display Text Large", you will lose the rich text, including the link, and even when you switch it back to "Display Text as a window" you have still lose the link. Try this out. It's quite curious.

Once a text field is marked as rich text, there are extra options that appear in the contest menu for selected text. For example, you get a "Font" submenu, which doesn't occur with plaintext because you can't change fonts in a plaintext document. Another submenu you get pertains to links, you can either create or remove them. But you can't get these features in a plaintext document.

It seems to me that the KM Editor automatically switches certain text boxes (such as Display Text) from plaintext to richtext when it detects a link before the cursor. And it seems that the KM Editor reverts any richtext box to plaintext when the box is empty.

I just tested this and I can co-sign on your theory. The goal is to figure out how to do this consistently. Only one person that I can think of can help. :smiley:

You mean Batman?

I found a way to copy from an existing RTF document and pasting into the Display Text action which forces the text to become rich text. And I found two ways to convert the Display Text box to switch back to plain text.

And I just remembered I started a thread about a very similar situation here. This allows you to see the RTF style ruler (in Keyboard Maestro > Edit > Format > Text). I think this may be an important clue, but this isn't in and of itself enough to enable the links. But I think I'm probably getting closer.