Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8956063
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:42:11+00:00 2026-06-15T14:42:11+00:00

I am trying to retreive text from another application by app’s control handle. I

  • 0

I am trying to retreive text from another application by app’s control handle. I have no problem if control is “static” but my code seems not working for “edit” control. As MSDN says, GetWindowText cannot retreive text from EDIT control but maybe you know another way of achieving this?

My current code is here:

Dim newHwnd As IntPtr = Handler.GetClassByPosition(ParentHwnd, cls, classPosition)
    Dim length As Integer = Handler.GetWindowTextLength(newHwnd)
    Dim sb As New String(" ".Chars(0), length + 1)
    If cls = "edit" Then
        Handler.GetWindowText(newHwnd, sb, sb.Length)
    End If

where GetClassByPosition returns control’s handle by specifying parent handle, class name (static,edit or button) and classPosition (used in loop – not important for now)

As I said, it works great with STATIC (labels etc) but it returns 0 if I’m retreiving text from EDIT (textbox) control of that external application.

UPDATE:

I have tried the following solution which success in returning data if data is integer but if it contains any letter, result is 0:

Dim tmpstr As IntPtr = Marshal.AllocHGlobal(100)
        Dim NumText = API.SendMessage(Hwnd, API.WM_GETTEXT, 200, tmpstr )
        NumText = Marshal.PtrToStringAnsi(tmpstr )
        Return NumText

Thanks in advance,
Nikola

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T14:42:13+00:00Added an answer on June 15, 2026 at 2:42 pm

    try this:

     Private Function GetText(ByVal hWnd As IntPtr) As String
    
        Dim ReturnValue As String = Nothing
    
        If hWnd.ToInt32 > 0 Then
    
            Dim Length As Integer = GetWindowTextLength(hWnd)
    
            If Length > 0 Then
    
                Dim sb As New System.Text.StringBuilder("", Length + 1)
    
                GetWindowText(hWnd, sb, sb.Capacity)
    
                ReturnValue = sb.ToString
    
                sb = Nothing
    
            End If
    
        End If
    
        Return ReturnValue
    
    End Function
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to get the text from a text box. I have 2 input
I'm trying to retrieve the text value from a JTextField but first I need
i'm trying to retrieve text from wikipedia to use on an Android app. I'm
I am trying retrieve user name from the code through graph api, the below
Iam trying to retrieve data from mysql database into stylesheet.php but it is not
Hi I am trying to retrieve values from database. I have a row which
I'm trying to retrive data from android sqlite database but its givine exception that
I am trying to retrieve a column from another related table, and display that
I am trying to retrieve a list of images and text from a web
I am trying to retrieve JSON data from an external text file using a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.