Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 185
  • Last Modified:

Read contents of another programs window?

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
edskee
Asked:
edskee
  • 3
  • 2
  • 2
  • +3
1 Solution
 
Richie_SimonettiIT OperationsCommented:
What's the program?
0
 
edskeeAuthor Commented:
Whats it matter?

Its another VB program someone else wrote whos source I dont have access to.
0
 
MonchangerCommented:
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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
edskeeAuthor Commented:
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
 
vinnyd79Commented:
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
 
Richie_SimonettiIT OperationsCommented:
edskee, good luck in your search.
Monchanger, thanks for explain that.
Cheers
0
 
MonchangerCommented:
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
 
Richie_SimonettiIT OperationsCommented:
well, well... not teaching indeed... iwas so lazy to do the explanation in my first post, that's all.
:D
0
 
HelixDaKatCommented:
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
 
DanRollinsCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 3
  • 2
  • 2
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now