CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9
  1. #1
    Join Date
    Jun 2000
    Posts
    8

    Grab window contents (text)

    Is there anyway of reading the contents of an external applicaiton's window?

    Maybe it's just a problem with the application whose window I wish to read (because it is some kind of 'secure' telnet application), but even using the SPY++ program with MS Visual Dev Studio I have been unable to find any kind of messages that seem to be printing/displaying text in that window.

    None of the WM_ or the EM_ messages have proved at all useful in this matter.
    Any other suggestions?

    regards,

    John.


  2. #2
    Join Date
    Apr 1999
    Posts
    396

    Re: Grab window contents (text)

    ::GetWindowText()


  3. #3
    Join Date
    Mar 1999
    Location
    Nepal
    Posts
    540

    Re: Grab window contents (text)

    ::GetWindowText() can be used to get the title of the parent, pop-up and child windows or the text from a control such as a button or edit control. But you have to get a handle to the appropriate control on the external application.


  4. #4
    Join Date
    Apr 1999
    Posts
    396

    Re: Grab window contents (text)

    Yes, I assumed he already had such handles. Of course if not, he could use EnumWindows() and EnumChildWindows() and GetWindow()


  5. #5
    Join Date
    Jun 2000
    Posts
    8

    Re: Grab window contents (text)

    I'm very grateful for your replies there people, but I'm affraid to say it hasn't helped enormously.

    You see GetWindowText() (as shree correctly pointed out) only gets the title bar text of a window. I require the actuall text being displayed INSIDE the window.

    The window in question is definitely not a control (hense the reason this function fails in getting its text)

    Also the window of the application was not created from the standard "edit" class (which would have made thing much simpler) but rather of class "Afx:400000:b:10009:0:0" - which I presume is a custom defined class (defined by the people who wrote the application)

    I'd be grateful for any other suggestion you can think of for getting access to this text.

    thanks,

    John.

    PS
    Window handles are not a problem, this much I can do.


  6. #6
    Join Date
    Apr 1999
    Posts
    396

    Re: Grab window contents (text)

    Unfortunately there isn't much you can do to get the window text. The tried and true method is by GetWindowText. If that doesn't work, well then the window procedure doesn't provide the option to get text via the WM_GETTEXT. Since it is a custom class there is really no way to determine how to get the text. Since it's in another process, you can't just pass a pointer to your buffer and send a million WM_USER+x messages and see if one works. Your best bet would be to contact whoever wrote the software and see if they have the appropriate documentation you need to get the text.


  7. #7
    Join Date
    Jun 2000
    Posts
    8

    Re: Grab window contents (text)

    thanks again for your input.

    We've tried asking the company for more information but they've been a little uncooperative.

    I've been working on various aspects of this project for several months now....does it really look like it is totaly impossible?

    oh well, it's been an experience.

    I thank you once more for your efforts.

    John.


  8. #8
    Join Date
    Mar 1999
    Location
    Nepal
    Posts
    540

    Re: Grab window contents (text)

    Well, I don't know if it is viable for you but if I were you and were stuck like this on a project I was working on for months, it wouldn't be a difficult task to write a basic OCR (the font would already be known) and read the text off the snapshot of the screen.


  9. #9
    Join Date
    Jun 2000
    Posts
    8

    Re: Grab window contents (text)

    hmmm, the trouble is this program is supposed to be a quick 'in the background, hardly even know it's there' kind of program. doing a print screen and then running a search thread every second or so to find out if the required text is there is a little on the unpractical side.

    I'd be very grateful for any other suggestions you might have though.

    John


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured