Results 1 to 2 of 2

Thread: Getting the text from another application's handle

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 1999
    Location
    Cleveland, Ohio
    Posts
    263

    Post

    How would I get the text from a text box in another application?

  2. #2
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177

    Post

    If you know the Handle of the Applications Textbox the you can use the SendMessage API with the WM_GETTEXT Constant, ie.
    Code:
    Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
    Private Const WM_GETTEXT = &HD
    
    Private Sub Command1_Click()
        Dim sText As String
        sText = Space(255)
        sText = Left$(sText, SendMessage(lHwnd, WM_GETTEXT, 255, ByVal sText))
        MsgBox sText
    End Sub
    Where lHwnd is the Handle of the Textbox.

    ------------------
    Aaron Young
    Analyst Programmer
    [email protected]
    [email protected]
    Certified AllExperts Expert

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