Jump to content

_ClipPutHTML


Ascend4nt
 Share

Recommended Posts

_ClipPutHTML

Okay, since I created the _ClipPutHyperlink() function, I figured I might as well just go one step further and open up the whole HTML Clipboard send/put interface and make it really simple to use - not only for simple Hyperlinks, but also for complete pieces of HTML code as well.

Note that 'PlainText' is the optional view of your HTML code that should be free of formatting. This is helpful when pasting to applications that don't accept HTML formatted strings, such as Notepad.

Note also that the HTML code NEEDS to be encoded in UTF-8 format. (For straight-ANSI/ASCII code, you don't need to do anything, UTF-8 encoding only comes into play for Unicode formatting).

Anyway, bundled in the ZIP is the UDF and a short example (same as the below HTMLPut Example).

Additionally, see the sample code for _ClipGetHTML().

Example 1: HyperlinkPut:

; Special Unicode text call
_ClipPutHyperlink("http://www.google.co.jp/",ChrW(0x30B0)& ChrW(0x30FC)& ChrW(0x30B0)& ChrW(0x30EB)& " (Japanese Google)")
; Regular text
_ClipPutHyperlink("http://www.google.com","Google")

- Example 'paste' Output -

Unicode Hyperlink:

グーグル (Japanese Google)

Regular Hyperlink:

Google

Example 2: HTMLPut

; Example is in 'Quote' because Code & AutoIt tags fail to handle this properly at the moment:

Local $sHTMLStr,$sPlainTextStr

$sHTMLStr='<html><head>'&@CRLF & " <title>Page Title</title>"&@CRLF & _

' <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">'&@CRLF & _

"</head>"&@CRLF & "<body>"&@CRLF & "<h1>Headline Text</h1>"&@CRLF & _

"<p>This is a paragraph showing the formatting possibilities using the "&@CRLF & _

'<a href="http://sites.google.com/site/ascend4ntscode/clipputhtml">_ClipPutHTML() functions</a>.'&@CRLF& _

" The regular modifiders, such as <strong>bold</strong>, <i>italics</i>, and <u>underlines</u> work as usual,"&@CRLF& _

" just like all other HTML formatting.</p>"&@CRLF & "<p>Â </p>"&@CRLF & _

"<p><strong>Here's an example list:</strong></p>"&@CRLF & "<ul>"&@CRLF & _

" <li>List <i>item</i> #1.</li>"&@CRLF & _

" <li>List <i>item</i> #2.</li>"&@CRLF & _

' <li>List <i>item</i> #3 with a <a href="http://www.google.com">Hyperlink</a></li>'&@CRLF & _

"</ul>"&@CRLF & "</body>"&@CRLF & "</html>"

$sPlainTextStr="Headline Text"&@CRLF&@CRLF& _

"This is a paragraph showing the formatting possibilities using the _ClipPutHTML() functions."& _

"The regular modifiders, such as bold, italics, and underlines work as usual, just like all other HTML formatting."&@CRLF&@CRLF& _

" Here's an example list:"&@CRLF& _

" * List item #1."&@CRLF& _

" * List item #2."&@CRLF& _

" * List item #3 with a Hyperlink"&@CRLF

_ClipPutHTML($sHTMLStr,$sPlainTextStr)

- Example 'paste' output -

Headline Text

This is a paragraph showing the formatting possibilities using the _ClipPutHTML() functions. The regular modifiders, such as bold, italics, and underlines work as usual, just like all other HTML formatting.

Here's an example list:

  • List item #1.
  • List item #2.
  • List item #3 with a Hyperlink

Get the Code at my Site

Ascend4nt's AutoIT Code License agreement:

While I provide this source code freely, if you do use the code in your projects, all I ask is that:

  • If you provide source, keep the header as I have put it, OR, if you expand it, then at least acknowledge me as the original author, and any other authors I credit

  • If the program is released, acknowledge me in your credits (it doesn't have to state which functions came from me, though again if the source is provided - see #1)

  • The source on it's own (as opposed to part of a project) can not be posted unless a link to the page(s) where the code were retrieved from is provided and a message stating that the latest updates will be available on the page(s) linked to.

  • Pieces of the code can however be discussed on the threads where Ascend4nt has posted the code without worrying about further linking.
Edited by Ascend4nt
Link to comment
Share on other sites

.. Edited by Ascend4nt
Link to comment
Share on other sites

  • 10 years later...

How do I write scecial characters with _ClipPutHTML funtion?

 

 

#include <_ClipPutHTML.au3>

$sHTMLStr='<html><head>'&@CRLF & "  <title>Page Title</title>"&@CRLF & _
'  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">'&@CRLF & _
"</head>"&@CRLF & "<body>"&@CRLF & "<h1>Headline Text</h1>"&@CRLF & _
"<p>" & "ófiéááéllááéáéá:" & Chr(225) & BinaryToString("á",4) &@CRLF & _
'<a href="http://www.autoitscript.com/forum/index.php?showtopic=96556">_ClipPutHTML() functions</a>.'&@CRLF& _
" The regular modifiders, such as <strong>bold</strong>, <i>italics</i>, and <u>underlines</u> work as usual,"&@CRLF& _
" just like all other HTML formatting.</p>"&@CRLF & "<p>&nbsp;</p>"&@CRLF & _
"<p><strong>Here's an example list:</strong></p>"&@CRLF & "<ul>"&@CRLF & _
"   <li>List <i>itemü</i> #1.</li>"&@CRLF & _
"   <li>List <i>itemá</i> #2.</li>"&@CRLF & _
 '  <li>List <i>itemé</i> #3 with a <a href="http://www.google.com">Hyperlink</a></li>'&@CRLF & _
"</ul>"&@CRLF & "</body>"&@CRLF & "</html>"

$sPlainTextStr="Headline Text"&@CRLF&@CRLF& _
"ófigyeljáéáéá" & Chr(225) & "_ClipPutHTML() functions."& _
"The regular modifiders, such as bold, italics, and underlines work as usual, just like all other HTML formatting."&@CRLF&@CRLF& _
"Here's an example list:"&@CRLF& _
"    * List itemü #1."&@CRLF& _
"    * List itemá #2."&@CRLF& _
"    * List itemé #3 with a Hyperlink"&@CRLF

;I have tired this way, but it does not work.
;$UTF8HTML = BinaryToString($sHTMLStr,4)
;ConsoleWrite($UTF8HTML)

;$sUTF8String=BinaryToString($sPlainTextStr,4)
ConsoleWrite($sUTF8String)

_ClipPutHTML($UTF8HTML,$sUTF8String)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...