Solved

Read contents of another programs window?

Posted on 2002-07-27
10
174 Views
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...
0
Comment
Question by:edskee
  • 3
  • 2
  • 2
  • +3
10 Comments
 
LVL 16

Expert Comment

by:Richie_Simonetti
Comment Utility
What's the program?
0
 
LVL 2

Author Comment

by:edskee
Comment Utility
Whats it matter?

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

Expert Comment

by:Monchanger
Comment Utility
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:
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=22932&lngWId=1
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=32191&lngWId=1

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...

Monchanger
0
 
LVL 2

Author Comment

by:edskee
Comment Utility
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.
0
 
LVL 28

Expert Comment

by:vinnyd79
Comment Utility
Check out this example.Just supply it the Window caption of the app you want to get data from.

http://www.freevbcode.com/ShowCode.Asp?ID=681
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 16

Expert Comment

by:Richie_Simonetti
Comment Utility
edskee, good luck in your search.
Monchanger, thanks for explain that.
Cheers
0
 
LVL 4

Expert Comment

by:Monchanger
Comment Utility
edskee,
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 :-)
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
Comment Utility
well, well... not teaching indeed... iwas so lazy to do the explanation in my first post, that's all.
:D
0
 
LVL 1

Accepted Solution

by:
HelixDaKat earned 100 total points
Comment Utility
edskee,

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

http://search.microsoft.com/gomsuri.asp?n=5&c=rp_Results&siteid=us/dev&target=http://msdn.microsoft.com/library/en-us/winui/winui/windowsuserinterface/windowing/windows/windowreference/windowfunctions/findwindow.asp

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

HelixDaKat
0
 
LVL 49

Expert Comment

by:DanRollins
Comment Utility
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
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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…

763 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now