I haven’t paid enough attention yet so I’ll ask, what do you use as the visible text then? Would you remove the link line in the comment and just link the task title?
This is what I use to create a RTF link for pasting into my attribution action:
--------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2019/04/17 02:19
# dMod: 2021/01/16 19:00
# Appl: Google Chrome, Keyboard Maestro
# Task: Create RTF Link for Keyboard Maestro Forum Thread Title and URL and Place on the Clipboard.
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @Google_Chrome, @Keyboard_Maestro, @Create, @RTF, @Link, @Forum, @Thread, @Title, @URL, @Clipboard
--------------------------------------------------------
try
set clipboardText to the clipboard as text
on error
set clipboardText to null
end try
tell application "Google Chrome"
tell front window
set theTitle to its title
if clipboardText ≠ null and clipboardText starts with "http" then
set theURL to clipboardText
else
set theURL to active tab's URL
end if
end tell
end tell
tell application "Keyboard Maestro Engine"
set theTitle to search theTitle for " +- .+$" replace "" with regex
end tell
--------------------------------------------------------
set shCMD to text 2 thru -1 of "
echo '<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">
<html>
<head>
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">
<meta http-equiv=\"Content-Style-Type\" content=\"text/css\">
<title>'\"$myTitle\"'</title>
<meta name=\"Generator\" content=\"Cocoa HTML Writer\">
<meta name=\"CocoaVersion\" content=\"1038.11\">
<style type=\"text/css\">
span.s1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 13.0px Lucida Grande}
</style>
</head>
<body>
<span class=\"s1\"><a href='\"" & theURL & "\"'>'\"" & theTitle & "\"'</a></span>
</body>
</html>' \\
| textutil -convert rtf -inputencoding UTF-8 -format html -stdin -stdout \\
| pbcopy -Prefer rtf
"
--------------------------------------------------------
do shell script shCMD
display notification "Link Copied to the Clipboard" with title "Google Chrome" subtitle "Script" sound name "Tink"
--------------------------------------------------------
(*
NOTES:
2020/12/18 10:24 -- Added ability to use an URL on the clipboard as the link.
*)
--------------------------------------------------------
The macro that downloads has a "Type the ⌘L Keystroke" action instead of the "Type the ⌘N Keystroke" action shown in the macro displayed above. This results in the creation of an alias macro, which is not what is wanted here.
In setting the comment, the Author and Url lines need an extra tab in front of the colon to even things up.
Also, the whole "wait until the favorite action has been added ..." bit was goofing things up on my computer, so I just replaced it with a pause, and all is now well.
Now I'm curious. So, on your keyboard, ⌘L creates a new macro? Is it a different language keyboard or something else? I.e. is it the keyboard itself, or have you reprogrammed the KBM commands to something else.
As a follow-on, what is the ⌘I keystroke in the downloaded version of the macro intended to do. That is where I was having the other problem.
Hope you don't mind my asking these things
Thanks! Yeah, it’s an interesting quirk of running a different keyboard layout. Come to think of it, I think you’ve inspired me to add a default note to my macros that I share in the future noting that I’m on Dvorak and the key bindings may need to be adjusted. I also should look into how to better deal with this. Thanks @rolian !
Hah, I now understand why your macro was clearing clipboards when it didn’t look to me like the macro was even copying anything. ⌘C (copy) on your keyboard was being translated to ⌘I when the macro downloaded to my computer, which explains why that whole check action was not working for me.