Results 1 to 13 of 13

Thread: How I can get the text of a textbox that is on other app?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Aug 2006
    Posts
    16

    How I can get the text of a textbox that is on other app?

    Hi all.

    (windows forms).

    How I can get the text of a textbox that is on other app?

    Example:
    I have an app running that has a textbox which Text property is "MICROSOFT VISUAL STUDIO ROCKS!".

    I want to make an application that will obtain the handle of that textbox and get its contents (its text property value). I already have the code that obtain the handle.

    I think that I need to use WM_GETTEXT in conjunction with OpenProcess, WriteProcessMemory, SendMessage and ReadProcessMemory. But I have no idea how to do it.

    Please help me.

    Thx in advance.
    Best regards,
    Marco Alves.

  2. #2
    Lively Member fifo's Avatar
    Join Date
    Dec 2005
    Location
    HaiPhong, Vietnam
    Posts
    77

    Re: How I can get the text of a textbox that is on other app?

    In order to do that, I alway follow step by step :

    1. Find Handle of window which you want to hook

    2. Find Handle of Textbox in this window you've founded

    3. Then, SendMessage TextBoxHandle, WM_GETTEXT,0,0 to get content of this TextBox

    Good luck!
    !Have fun!

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Aug 2006
    Posts
    16

    Re: How I can get the text of a textbox that is on other app?

    sorry for my ignorance, but I think that this don't work across process boundaries. can you help ?

  4. #4
    Lively Member fifo's Avatar
    Join Date
    Dec 2005
    Location
    HaiPhong, Vietnam
    Posts
    77

    Re: How I can get the text of a textbox that is on other app?

    Oh, I think you should google to "Hooking and Subclassing in VB" , this ebook would be useful for you.

    You can post your simple code? I need to know more about your project.
    !Have fun!

  5. #5
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: How I can get the text of a textbox that is on other app?

    WM_GETTEXT is OK across process boundaries.

    AFAIK any message below WM_USER can be used across processes because the OS will handle transferring the data for you.

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Aug 2006
    Posts
    16

    Re: How I can get the text of a textbox that is on other app?

    I will post my code here to you see it and help me...

  7. #7
    Frenzied Member ice_531's Avatar
    Join Date
    Aug 2002
    Location
    Sitting w/ Bob Status: -Next -To- Null- Friend: Philip
    Posts
    1,152

    Re: How I can get the text of a textbox that is on other app?

    Search the forums; this has been asked and answered many times.

    Also look into getting patorjkapispy

    very easy for things like you are doing.

    Also check the API FAQs for some of my posts, i know i posted a sample project on how to send/get text from an msn window given partial window caption i believe.
    :::`DISCLAIMER`:::
    Do NOT take anything i have posted to be truthful in any way, shape or form.
    Thank You!

    --------------------------------
    "Never heard about "hiking" poles. I usualy just grab a stick from the nature, and use that as a pole." - NoteMe
    "Finaly I can look as gay as I want..." - NoteMe
    Languages: VB6, BASIC, Java, C#. C++

  8. #8
    Frenzied Member ice_531's Avatar
    Join Date
    Aug 2002
    Location
    Sitting w/ Bob Status: -Next -To- Null- Friend: Philip
    Posts
    1,152

    Re: How I can get the text of a textbox that is on other app?

    :::`DISCLAIMER`:::
    Do NOT take anything i have posted to be truthful in any way, shape or form.
    Thank You!

    --------------------------------
    "Never heard about "hiking" poles. I usualy just grab a stick from the nature, and use that as a pole." - NoteMe
    "Finaly I can look as gay as I want..." - NoteMe
    Languages: VB6, BASIC, Java, C#. C++

  9. #9
    Frenzied Member
    Join Date
    Aug 2000
    Posts
    1,091

    Re: How I can get the text of a textbox that is on other app?

    What if the textbox is on a child form within the application (not MDI) and is on a tab control? Do I need to first fine the address of the main window, then the child window, then the tab control to get to the textbox I want to read from?

    Visual Studio 2010

  10. #10
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: How I can get the text of a textbox that is on other app?

    You can use FindWindowEx to get a child window, or EnumChildWindows.
    Not sure what you mean by "main window". Any window that is not enclosed within another window (as a textbox is) can be found using FindWindow.

  11. #11
    Frenzied Member
    Join Date
    Aug 2000
    Posts
    1,091

    Re: How I can get the text of a textbox that is on other app?

    Okay, I've got this working to a point. Now, on the screen where I want to read from a particular textbox, there are more than one textbox on the screen with the same Class name. How do I specify that I want to read from a certain textbox? I'm using the following code to read the text, but again, it's reading from the first textbox on the screen, I want to read from the second one.

    VB Code:
    1. If hwnd Then
    2.         '-- grab text out of textbox
    3.         hwnd2 = FindWindowEx(hwnd, 0, "Edit", vbNullString)
    4.         If hwnd2 Then
    5.             SetForegroundWindow hwnd
    6.             ret = SendMessage(hwnd2, WM_GETTEXTLENGTH, 0, 0)
    7.             buffer = Space(ret)
    8.             ret = SendMessageByString(hwnd2, WM_GETTEXT, ret + 1, buffer)
    9.             MsgBox buffer
    10.         End If
    11.     End If

    Visual Studio 2010

  12. #12
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: How I can get the text of a textbox that is on other app?

    Does it have a window name?

    Otherwise, you will have to use EnumChildWindows.

  13. #13
    Addicted Member Beasts's Avatar
    Join Date
    Oct 2006
    Posts
    147

    Re: How I can get the text of a textbox that is on other app?

    Hey! Can 1 of you guyz post the whole code?
    i dont understand it! But i think i am in need of it too. I dont understand all that you guyz have said much. So please post a full code that once copy pasted can work? [I]with tips please!

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