Caputring Text From a 3rd Party RichEdit Chat Window

O

oracle3001

Hi All,

I want to capture / read the text flowing through a chat window that
is part
of an external application. I should note that I don't just want to
capture
the text in the chat window once, I want to get the new text as and
when it
is posted into the chat window

I have little knowledge of the windows api so a simple explanation or
sample
code would be much appreciated.

Adam
 
J

Jon S.

Hi Adam,
What you need to do is first get the window's HWND
i.e:
HWND mywindow = ::FindWindow("MyWindowClassName", "WindowTitleName"); <<
Note that either parameter can be set to NULL, but not both.
Then you use FindWindowEx() using the parent HWND, in this case, mywindow in
order to get to the edit box you want to get text from.

Once you've gotten to the HWND of the edit box you can get the text by
doing the following:

::SendMessage(wndofeditbox,WM_GETTEXT,strlen(mytext),LPARAM(mytext));

where mytext is a variable i.e char[], to hold string data. And there you
have the editbox's data

As for constantly updating it: I reccomend using Threading. devote a worker
thread to update the text I believe that would be best.

callbacks & threading:

http://www.flounder.com/callbacks.htm

info on findwindowex:
http://www.google.com/search?hl=en&ie=UTF-8&q=findwindowex



Jon
 
W

William DePalo [MVP VC++]

oracle3001 said:
I want to capture / read the text flowing through a chat window that
is part of an external application. I should note that I don't just want
to
capture the text in the chat window once, I want to get the new text as
and
when it is posted into the chat window

If the window is an "edit control" or a "rich edit" control then an option
to read the text is to send it a message or messages such as
WM_GETTEXTLENGTH and WM_GETTEXT. If it is something else, you'd either have
to know something about the class of window that it is or use some optical
character recognition like scheme.
I have little knowledge of the windows api so a simple explanation or
sample code would be much appreciated.

Well, then I'm sorry to tell you that this isn't easy. Sending a message to
a common control to poll it for its text is easy. To invade another process
to the point of being able to react to changes as they occur is reasonably
difficult. The usual tack would involve planting a system wide hook, doing
something to trigger the hook so that you could subclass the window and then
have the subclassed window procedure running at this point in the external
application send a notification to your application detailing the change.

It is far more to explain than can be done in a newsgroup post. If you want
to pursue this I suggest you read a good book on Windows programming along
the lines of something by Jeffrey Richter class "Advanced Windows".

Regards,
Will
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top