Is it possible to copy the contents of the HTMLViewer with Ctrl-C like command?
From which platform ?
Excuse me, OSX. I think Applescript will do the trick.
You can also get the HTML source with routines described in https://forum.xojo.com/2599-htmlviewer-source save that to disk and convert to TXT, RTF or DOC using Textutil through a shell.
could you explain about TextUtil?
Is it not possible to use the Keydown event ?
Or is your question about getting the source from HtmlViewer
[quote=76327:@John Hansen]Is it not possible to use the Keydown event ?
Or is your question about getting the source from HtmlViewer[/quote]
No, not the source, that’ easy. I want to programmatically do Command-A Command-C
As far as I remember AppleScript can do this or pressky from http://www.monkeybreadsoftware.net/example-computercontrol-presskey-writesomething.shtml .
TextUtil is an OS X command line that converts between RTF, RTFD, DOC, DOCX, ODT, TXT, HTML, WORDML (XML), WEBARCHIVE.
So from the command line or from a shell converting the HTML source to RTF would be done as :
TextUtil -convert rtf -output myfile.rtf myfile.html
You can get all the commands by typing man TextUtil.
I use textutil in my apps though a shell. It is fast and reliable.
I will look into that.
'get html source
dim s as string
dim h as new HTTPSocket
'write the html to a file
dim f as folderitem = Specialfolder.Temporary.Child(“myfile.html”)
dim t as TextOutputStream = TextOutputStream.Create(f)
'Convert to TXT with Textutil
dim theshell as new shell
dim f2 as folderitem = Specialfolder.Temporary.Child(“myfile.txt”)
theshell.Execute("textutil -convert txt -output “+f2.Shellpath+” "+f.ShellPath)
'Load TXT in TextArea
dim t2 as TextInputStream = TextInputStream.Open(f2)
if t2 <> nil then
//Read all of t2 into TextArea1.text
TextArea1.Text = t2.readAll // field is passed as a TextArea
msgbox(“Error opening file”)
I used TXT because normal RTF load time is too long.
Thanks for the code. Very kind. I will test it tomorrow.
Works like a charm!
In the Menu: Edit->Copy’s Menu Handler code add the following code:
Select the text and press Ctrl+C
The text gets copied to the clipboard
It work like a charm.