rudi Posted August 4, 2020 Share Posted August 4, 2020 (edited) Hello, I want to put a URL as "clickable-copy-paste" within some text to the clipboard, so that it can be used in WinWord, Outlook, .... This code is formatting the text properly in a RichText Edit, but when taking the content to the clipboard, the "clickable" of the URL get's lost. expandcollapse popup#include <GuiRichEdit.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <Color.au3> $TxtTop="Your download will be available for 14 days only:" & @CRLF & _ "http://download.company.com/Your-Personal-Data-Collection.zip" $TxtChecksum= @CRLF & @CRLF & "File Name: Your-Personal-Data-Collection.zip" & @CRLF & _ "File Size: 93440288 Bytes (89 MiB)" & @CRLF & _ "SHA256: 8B1D4F670501A7FEEC2CABE2E731EF7B34042570EE2A2579E91DO9AD7EBE7419" PutToClipWithFormatting($TxtTop,$TxtChecksum) Func PutToClipWithFormatting($TextDefault, $TextCourierNew6) Local $hGui, $iMsg, $idBtnNext, $iStep = 0 Local $GuiW=800 Local $GuiH=300 $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")",$GuiW,$guiH) $g_hRichEdit = _GUICtrlRichEdit_Create($hGui, "", 10, 10, $GuiW - 20, $GuiH - 20, BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL)) GUISetState(@SW_SHOW) _GUICtrlRichEdit_AppendText($g_hRichEdit,$TextDefault) MsgBox(0, '', "after adding some text including an URL") _GUICtrlRichEdit_AutoDetectURL($g_hRichEdit,True) ; URL Autodetection MsgBox(0, '', "after calling AutoDetectURL") _GUICtrlRichEdit_SetSel($g_hRichEdit, -1, -1) ; set selection behind last CHAR in RTF_EDIT _GUICtrlRichEdit_SetFont($g_hRichEdit, 8, "Courier New") ; change font to 8pt, Courier New Dim $aRGB[3]=[230,230,230] Dim $ColRef=_ColorSetCOLORREF($aRGB) _GUICtrlRichEdit_SetCharColor($g_hRichEdit, $ColRef) _GUICtrlRichEdit_AppendText($g_hRichEdit, @CRLF & $TextCourierNew6) _GUICtrlRichEdit_AppendText($g_hRichEdit, @CRLF & "Web Site: http://www.company.com/") _GUICtrlRichEdit_SetSel($g_hRichEdit, 0, -1) ; select all the content of the RTF_EDIT _GUICtrlRichEdit_Copy($g_hRichEdit) ; put the selection to the clipboard MsgBox(0, '', "After taking all content of RT to ClipBoard.") GUIDelete($hGui) EndFunc ;==>Example The "Gray-8pt-Courier New" formatting is taken correctly to the clipboard, but not the "clickable" of the URL. What do I miss? Regards, Rudi. Edited August 4, 2020 by rudi Earth is flat, pigs can fly, and Nuclear Power is SAFE! Link to comment Share on other sites More sharing options...
Nine Posted August 4, 2020 Share Posted August 4, 2020 Works for me. Pasted it in a Word document and all the RTF were copied... “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Dan_555 Posted August 4, 2020 Share Posted August 4, 2020 @rudi Try to compile the Exe in 32 and 64 bit. I think it may be up to this. Some of my script sourcecode Link to comment Share on other sites More sharing options...
rudi Posted August 4, 2020 Author Share Posted August 4, 2020 (edited) Confused: It doesn't work for me. Not when started from SciTE <F5> when editing the script not when compiled 32bit not when compiled 64bit This is now a different Windows 10 Pro 64bit PC I'm sitting at. Differences are, that on this machine there is a 32bit Office 2013 installed. That one at work is 64bit Windows as well, but a 64bit Office 2016. Edited August 4, 2020 by rudi Earth is flat, pigs can fly, and Nuclear Power is SAFE! Link to comment Share on other sites More sharing options...
rudi Posted August 6, 2020 Author Share Posted August 6, 2020 @Nine Could you please confirm or withdraw your information, that when pasting into WinWord the URLs are both clickable? Today I've tried some other PCs, Win7, Win10, and offices from version 2003 to 2016, 32bit, 2016 64bit Office as well. For me *NONE* of the machines a "Paste" ended up with a clickable URL (WinWord an Outlook) Regards, Rudi. Earth is flat, pigs can fly, and Nuclear Power is SAFE! Link to comment Share on other sites More sharing options...
rudi Posted August 6, 2020 Author Share Posted August 6, 2020 Any other aproach to modify a clipboard content so that URLs will be "hold-in-ClipBoard-as-clickable" ? Regards, Rudi. Earth is flat, pigs can fly, and Nuclear Power is SAFE! Link to comment Share on other sites More sharing options...
Dan_555 Posted August 6, 2020 Share Posted August 6, 2020 (edited) I do not have WinWord nor Outlook. I have Apache Open Office, and it does not make a clickable url because of the security settings. Are the urls clickable when you type them in ? Edited February 13, 2021 by Dan_555 deleted the attached picture Some of my script sourcecode Link to comment Share on other sites More sharing options...
Nine Posted August 6, 2020 Share Posted August 6, 2020 (edited) On 8/6/2020 at 4:01 PM, rudi said: Could you please confirm or withdraw your information I can confirm it is working for me Edited March 31, 2023 by Nine “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Nine Posted August 6, 2020 Share Posted August 6, 2020 I think @Dan_555 has touch the root of your problem. There is multiple places where you can remove the right to display URL as they are a potential threat. I suggest you explore that direction. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
rudi Posted August 6, 2020 Author Share Posted August 6, 2020 Thanks for your reply, I believe this is *NOT* a rights issue at all, but the way the RichText Functions work -- in my opinion, don't work properly. It's working as a charm using the UDF _ClipPutHTML.AU3 by @Ascend4nt in this thread: #include <_ClipPutHTML.au3> ; =============================================================================================================================== ; <TestClipPutHTML.au3> ; ; Test of <_ClipPutHTML.au3> ; ; Author: Ascend4nt ; =============================================================================================================================== Local $sHtmlPre Local $sURL = "http://download.company.com/Your-Personal-Download.ZIP" Local $sSHA = "SHA256 CheckSum = XXXX" Local $HtmlSuff = @CRLF & "</body>" & @CRLF & "</html>" Local $sHTMLStr Local $sPlainTextStr $sHtmlPre = '<html><head>' & @CRLF & _ '<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">' & @CRLF & _ "</head>" & @CRLF & "<body>" & @CRLF $sHTMLStr = $sHtmlPre & _ "The following download will be available for 7 days ONLY: <br>" & @CRLF & _ '<a href="' & $sURL & '">' & StringTrimLeft($sURL, StringInStr($sURL, "/", 0, -1)) & '</a><br>' & @CRLF & _ '<font face="Courier New" size="-2" color="#bbbbbb">' & $sSHA & '</font><br>' & _ $HtmlSuff $sPlainTextStr = "The following download will be available for 7 days ONLY: " & @CRLF & _ @TAB & $sURL & @CRLF & _ @TAB & $sSHA & @CRLF _ClipPutHTML($sHTMLStr, $sPlainTextStr) The clipboard content has both in it "all-in-one": HTML formatted content with the clickable URLs as wanted alternative "Plain-TXT-only" content, used e.g. when the email formatting is set to "plain-text-only" Just a small modification was required, as the compiler complained for "missing separator character before keyword": Func _ClipBoard_SendHTML(Const ByRef $sHTMLData,Const ByRef $sPlainText) Okay --> Func _ClipBoard_SendHTML(Const ByRef $sHTMLData , Const ByRef $sPlainText) Regards, Rudi. Earth is flat, pigs can fly, and Nuclear Power is SAFE! Link to comment Share on other sites More sharing options...
Nine Posted August 7, 2020 Share Posted August 7, 2020 I cannot help further since I cannot replicate your issue. But glad you have found a solution... “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now