After some googling and goggling, I got:

          {initialization}
           OleInitialize(nil);

           Application.ProcessMessages;
           wbDocument.ExecWB(OLECMDID_SELECTALL, OLECMDEXECOPT_PROMPTUSER);
           Application.ProcessMessages;
           wbDocument.ExecWB(OLECMDID_COPY, OLECMDEXECOPT_PROMPTUSER);

          {finalization}
           Application.ProcessMessages;
           OleUninitialize;
           Application.ProcessMessages;

           reText.PasteFromClipboard;

But unfortunately, right after the "OLECMDID_SELECTALL", I get a message
about "... not registered as drop target" which thoroughly confuses me.  The
TWebBrowser property "RegisterAsDropTarget" is set at the default True and
never changes.  Also, the "RegisterAsBrowser" is set False by default, and
my program never changes it.  

Can I do the OleInitialize .. OleUnInitialize in pairs like that? 

Can anyone shed some insight into this situation?  I just want to do a
SelectAll and then a CopyToClipBoard in sequence for a TWebBrowser.  That's
it.  Then I will do a PasteFromClipBoard in a TRichEdit in its "Text"
property and all will be well.  At least, it works when I do it myself with
key sequences.  

Thanks,
-Rich
 
Sincerely,
Rich Cooper
EnglishLogicKernel.com
Rich AT EnglishLogicKernel DOT com

-----Original Message-----
From: delphi-boun...@elists.org [mailto:delphi-boun...@elists.org] On Behalf
Of Rich Cooper
Sent: Wednesday, February 03, 2010 11:46 AM
To: 'Moderated List for the Discussion of Delphi
ProgrammingexcludingDatabase-related topics'
Subject: TWebBrowser doing "Ctrl-A" or "Select All" to get text

Hi Everybody,

Using D7, TWebBrowser, as the program runs, I can hit the key chord Ctrl-A,
Ctrl-A to select and then copy the text and other stuff displayed inside a
TWebBrowser.  Then I select the target and hit a Ctrl-V to paste it into a
TMemo or a TRichEdit.  

But I want the PROGRAM to do that!  How can I get my running TWebBrowser
based program to copy the displayed text as though I had done Ctrl-A,
Ctrl-C, then select and Ctrl-V?

I tried the obvious approach of reading the TWebBrowser docs, the Indy docs,
and so on.  When the extension of the URL is a text-type file (htm, html,
txt, rtf, ...) the following works:

        reText.Text := HTTP.Get(URLpart);

But when the extension is non-text (pdf, none, ...) the program goes into a
never ending loop looking for text among the binary ruins.  So I need a way
to do the [ Select-All | Copy | <select target> | Paste ] sequence
programmatically when the extension is non textual.  The last part, I can
do.  It's the first part that I haven't figured out:

Does anyone have a suggestion on how to [ Select-All | Copy ] in a
TWebBrowser, or TIdHTTP or some such component?  D7, Vista & XP targets.  
 
Sincerely,
Rich Cooper
EnglishLogicKernel.com
Rich AT EnglishLogicKernel DOT com

_______________________________________________
Delphi mailing list
Delphi@elists.org
http://lists.elists.org/cgi-bin/mailman/listinfo/delphi

_______________________________________________
Delphi mailing list
Delphi@elists.org
http://lists.elists.org/cgi-bin/mailman/listinfo/delphi

Reply via email to