Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
create hyperlink with alternative text on clipboard
A link to a webpage often displays an alternative text rather then the URL address. Like when it says: "You can find this here." (where 'here' is a different color and you can click on it which takes you to the webpage). 

I would like to have a macro that takes a string (containing a URL) as input, and stores this as a link with an alternative text (for instance the word 'here') on the clipboard. So that (after I have run the macro) I can paste it where I need it (and it shows as the alternative text that is clickable and takes you to the webpage). 

I have no idea how to do this.   Any suggestions?
Here you can find function PasteHtml. Replace setsel with setclip.
Thank you, it works!

One small detail, the function PasteHtml seems to add a newline character at the end of the selection (or clipboardcontents when using .setclip instead of .setsel).  Is it possible to prevent this?

This is the code I have:

Macro LinkFromClipboardText
Copy      Help
str s.getclip  ;; get url from the clipboard
str html.from("<a href=''" s "''>here</a>")  ;;create the link

str sh.format("Version:1.0[]StartHTML:00000033[]%s" html)
sh.setclip("HTML Format")
It depends on HTML, and maybe on the target program. For example, PasteHtml "<i>italy</i>" does not add a newline in my tested programs.
Okee, thanks.

Forum Jump:

Users browsing this thread: 1 Guest(s)