Solved

Read contents of another programs window?

Posted on 2002-07-27
10
175 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
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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Help in WHSCRIPT 9 47
I need help formating a date variable in my VB.Net application 2 44
Run code from text file in vb 1 56
Access query that references subform 5 43
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

919 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

20 Experts available now in Live!

Get 1:1 Help Now