Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


Read contents of another programs window?

Posted on 2002-07-27
Medium Priority
Last Modified: 2010-05-02
I'm a moderately experienced VB programmer, and I know this can be done, but need to know where to start looking.

I want to write a program that can read the contents of another programs forms/windows. I know it's possible, there are tons of programs that read chat windows and email and the like in AOL.

All I need to do is grab one specific window from one specific program, and copy the text in it to a local variable so I can manipulate it.

If anyone can point me in the right direction... a webpage reference, maybe some sample code to get started, it'd be much appreiciated.

Thanks for any help...
Question by:edskee
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +3
LVL 16

Expert Comment

ID: 7183102
What's the program?

Author Comment

ID: 7183106
Whats it matter?

Its another VB program someone else wrote whos source I dont have access to.

Expert Comment

ID: 7183134
It could save you a lot of time by saying "I want to do this only for MS Word", because there is a special technique to accessing MS Office products (Automation). This applies to a few more applications whose authors decided to write it that way, but not very common in general. If your specific application is like this, accessing would be real easy.

If you're interested in being able to access the on-screen data from *any* application, the method I've seen work best is what  they do at Babylon (http://www.babylon.com/).
The method they use is:
1) Do a screen capture of the text around the mouse cursor (you could modify this to capture a specific application's window, and then grab a certain area of the window).
2) Run the captured image through OCR (optical character recognition - which translates an image to text).

This method is far from being the easiest piece of software to write, especially the OCR part. You *can* find some free code on OCR here and there on the net, but I'm guessing you get what you pay for.

I ran a searche on OCR and found:

Finally, I once thought about writing something like this and thought that it *might* be possible to read the strings directly from memory, as I believe the text would be stored somewhere in RAM (as the "text" property of a textbox is first of all a member variable and only later a graphic image) while the image of the text sat in video memory. I never actually investigated this train of thought further...


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.


Author Comment

ID: 7183579
Thats an absolutely horrible way to do it. On a newsgroup, someone pointed me in the right direction. Api's exist to do this, you dont need to do a screen capture and OCR the bitmap. You also dont need to scan memory for it either.
LVL 28

Expert Comment

ID: 7183608
Check out this example.Just supply it the Window caption of the app you want to get data from.

LVL 16

Expert Comment

ID: 7183837
edskee, good luck in your search.
Monchanger, thanks for explain that.

Expert Comment

ID: 7184404
First of all - you're welcome.
Next, would you care to enlighten us? It would be nice to have the answer in the PAQ.

Richie- glad I could teach you something :-)
LVL 16

Expert Comment

ID: 7185631
well, well... not teaching indeed... iwas so lazy to do the explanation in my first post, that's all.

Accepted Solution

HelixDaKat earned 400 total points
ID: 7187154

   From what I can see you are wanting to know about the API function FINDWINDOW.


This will get you the hWnd (Handle) of the window you are wanting to Screen Scrape.

Also, if you where to provide information as to what kind of control this information was coming from (Textbox, Label, Grid, ect...) it would help in answering your question in more detail.

Hope this helps

LVL 49

Expert Comment

ID: 8049032
Hi edskee,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Save as PAQ -- No Refund.

edskee, Please DO NOT accept this comment as an answer.
EXPERTS: Post a comment if you are certain that an expert deserves credit.  Explain why.
DanRollins -- EE database cleanup volunteer

Featured Post

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question