I am trying to solve a problem using KM actions, as opposed to an AppleScript because I want to be able to make modifications and adaptions in the future.
The macro below inserts the frontmost Chrome Title → highlight the title → create Link (Cmd-K) → insert the URL
I want to end up with a robust macro which yields:
The problem with the macro below is the section action which highlights the title. It is not robust and creates unpredictable outcomes when the title is multi line (as when the window I am working in is narrow) or when there is text on the same line behind the title (which is selected and included in the title to create the link)
I don't have Chrome, so I tested this with Safari. Also for testing, I used TextEdit, so you may need to adjust this for whatever app(s) you're using. And credit to @peternlewis for the approach he showed in this thread about getting the cursor position, which I mildly reformulated to circumvent AppleScript which you wanted to avoid.
Two notes: As designed, this macro assumes there will be no text after the point at which you're inserting the Chrome title. And where H3R3 is shown in the macro, there is a space after it.
Sorry, ronald, but you will need a script, specifically a shell script, to create a rich text hyperlink that you can paste into any rich text document.
There may be a few, app-specific, workarounds that involve pasting the link text, selecting the text, and then use the app's menu to create a hyperlink. It can be done, but is not very robust.
The shell script is very simple, and there should not be a need to modify it.
There are many, many things that KM native non-script Actions can do, but this isn't one of them.
Here's the Shell Script:
This has been used by many people for years.
Here's the full Macro to Set the Clipboard to a Hyperlink:
All you need to change are the magenta Actions that set the data for the Shell Script.
Below is just an example written in response to your request. You will need to use as an example and/or change to meet your workflow automation needs.
thank you very much. Although I decided to go with @JMichaelTX 's macro, I will definitely keep in mind the trick of using Find to highlight and insert a link