Thread: Get text from other window

  1. #1
    Registered User
    Join Date
    Aug 2008
    Posts
    3

    Get text from other window

    Hello,
    I have a problem, I need to read text from a text box in another application.
    Using Spy++ I found that the text box's class is Internet Explorer_Server
    I tried SendMessage and a few other functions but it didn't work.

    Thanks in advance.
    Last edited by Adrian++; 08-03-2008 at 11:36 AM.

  2. #2
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    GetWindowText API function.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    Registered User
    Join Date
    Aug 2008
    Posts
    3
    GetWindowText can get only the Text from the main window (if you give it a HWND from another process)

  4. #4
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    No, that's incorrect. Pass the correct HWND to GetWindowText and it will retrieve the text.
    It works with edit controls, as well.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  5. #5
    Registered User
    Join Date
    Apr 2007
    Posts
    137
    Quote Originally Posted by Elysia View Post
    No, that's incorrect. Pass the correct HWND to GetWindowText and it will retrieve the text.
    It works with edit controls, as well.
    No.
    Read the doc :"GetWindowText cannot retrieve the text of a control in another application."
    Use any other known method

  6. #6
    Registered User
    Join Date
    Oct 2007
    Posts
    242
    I'm not sure if will can work with textboxes but anyways, you can also use pipes.

  7. #7
    Registered User
    Join Date
    Mar 2005
    Location
    Mountaintop, Pa
    Posts
    1,058
    Here is a thread that discusses this issue in detail

  8. #8
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    As I seem to recall, GetWindowText just sends WM_GETTEXT, which is the method to retrieve the text from a control (indeed, I have been doing this for ages using MFC).
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  9. #9
    60% Braindead
    Join Date
    Dec 2005
    Posts
    379
    (I think) He wants to get text from an application which is not related to his. I dont know of any basic API function for this, you'd probably need some sort of hook to intercept the text flowing to the other programs controls.
    Code:
    Error W8057 C:\\Life.cpp: Invalid number of arguments in function run(Brain *)

  10. #10
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    So what you are implying is that you can't use GetWindowText for controls outside your own window?
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C or C++
    By AcerN30 in forum Game Programming
    Replies: 41
    Last Post: 05-30-2008, 06:57 PM
  2. Adding buttons, edit boxes, etc to the window
    By rainmanddw in forum Windows Programming
    Replies: 1
    Last Post: 04-10-2006, 03:07 PM
  3. Window scrollbar
    By maxorator in forum Windows Programming
    Replies: 2
    Last Post: 10-07-2005, 12:31 PM
  4. Adding colour & bmps to a Win 32 Window??
    By carey_sizer in forum Windows Programming
    Replies: 4
    Last Post: 09-04-2004, 05:55 PM
  5. problem with open gl engine.
    By gell10 in forum Game Programming
    Replies: 1
    Last Post: 08-21-2003, 04:10 AM