?
Solved

Read contents of another programs window?

Posted on 2002-07-27
10
Medium Priority
?
181 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
[X]
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
10 Comments
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7183102
What's the program?
0
 
LVL 2

Author Comment

by:edskee
ID: 7183106
Whats it matter?

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

Expert Comment

by:Monchanger
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:
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 2

Author Comment

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

Expert Comment

by:vinnyd79
ID: 7183608
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
 
LVL 16

Expert Comment

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

Expert Comment

by:Monchanger
ID: 7184404
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
ID: 7185631
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 400 total points
ID: 7187154
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
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
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

764 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