Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

copy selected text in another application

186 views
Skip to first unread message

Edwin

unread,
Jul 26, 2007, 10:32:09 PM7/26/07
to
Hi,

I want to copy the selected text in a window of another app, I think
there are at least two approaches to do it:

1. send a WM_COPY message to the target window. not tried yet but
somebody said that IE dose not response to this message.
2. send key combination ctrl+C to the target window, will this work with
all windows?

Any tips and comments are welcomed. Thanks.

Edwin -- MindVisualizer -- Productive Visual Mind Mapping Software
http://www.innovationgear.com

Remy Lebeau (TeamB)

unread,
Jul 27, 2007, 2:28:01 AM7/27/07
to

"Edwin" <nos...@domain.com> wrote in message
news:46a9...@newsgroups.borland.com...

> 1. send a WM_COPY message to the target window.
> not tried yet but somebody said that IE dose not
> response to this message.

To copy text from an IE browser window, you have to extract the
IHTMLDocument2 interface from the window first:

How to get IHTMLDocument2 from a HWND
http://support.microsoft.com/kb/249232

With that, you can then access the selected text via the selection property:

IHTMLDocument2::selection Property
http://msdn2.microsoft.com/en-us/library/aa752606.aspx

Or you can use the execCommand() method to send a Copy command:

IHTMLDocument2::execCommand Method
http://msdn2.microsoft.com/en-us/library/aa752577.aspx

> 2. send key combination ctrl+C to the target window,
> will this work with all windows?

Not all, no.


Gambit

Edwin

unread,
Aug 11, 2007, 6:16:32 AM8/11/07
to


Thanks for your great information!

0 new messages