Get text from child window in another program (

I'm writing a simple app in VB.Net to carry out a task after a third party application has downloaded information from the internet.

When the third party application is not connected to the internet, the status bar at the bottom of its window is blank. When the third party application is connected to the internet and is downloading data, text appears in the status bar.

Using the Microsoft utlitity Inspect Objects (Inspect.exe), I can see that the program's main window has four children: a pane, a menu bar, a status bar, and the title bar of the main window.

I have been able to get the hWnd of the status bar using this code:

Imports System.Runtime.InteropServices
Imports System.Text

Public Class Form1
    <DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
    Private Shared Function FindWindowEx(ByVal parentHandle As IntPtr, _
                                         ByVal childAfter As IntPtr, _
                                         ByVal lclassName As String, _
                                         ByVal windowTitle As String) As IntPtr
    End Function
    Declare Auto Function FindWindow Lib "user32.dll" (ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim ParentHWND As IntPtr = FindWindow("", "Control Center - W1")
        Dim ChildHWND As IntPtr = IntPtr.Zero
        Const ChildClassName As String = ""
        Dim StatusStripHWND As IntPtr = IntPtr.Zero

        ChildHWND = FindWindowEx(ParentHWND, ChildHWND, ChildClassName, String.Empty)
        Label_FirstChild.Text = ChildHWND
        ChildHWND = FindWindowEx(ParentHWND, ChildHWND, ChildClassName, String.Empty)
        Label_SecondChild.Text = ChildHWND
        ChildHWND = FindWindowEx(ParentHWND, ChildHWND, ChildClassName, String.Empty)
        Label_ThirdChild.Text = ChildHWND

        StatusStripHWND = ChildHWND
    End Sub
End Class

Open in new window

Inspect.exe shows that the status bar has three children, all of which are text controls (ControlType: UIA_TextControlTypeId (0xC364)).

My question is: How can I retreive the text currently displayed on the second text control in the status bar (highlighted in blue on the attached screenshot).

Screenshot showing second text control highlighted
W CoderAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ste5anSenior DeveloperCommented:
Depends on the control. Whether the text is displayed in a windo or not. I would use Get Window and GetWindowText or SendMessage() with WM_GETTEXT.
W CoderAuthor Commented:
Thanks ste5an for your reply.  As far as I understand, GetWindowText cannot be used to get text on a control in another app.

I have tried the following using WM_GETTEXT, but it unfortunately returns nothing in the message box.

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
    End Sub

    Private Sub GetText(ByVal WindowHandle As IntPtr)
        Dim TextLen As Integer = SendMessage(WindowHandle, WM_GETTEXTLENGTH, 0, 0) + 1
        Dim Buffer As String = New String(" "c, TextLen)
        SendMessageByString(WindowHandle, WM_GETTEXT, TextLen, Buffer)
    End Sub

Open in new window

The text I am trying the retrieve appears in the 'Name' field in the right-hand pane of Inspect.exe (see attached screenshot) Could the fact that the text appears in the Name field offer any clue as to how to retrieve it?  

What I'm trying to say is that if Inspect.exe can see the text, it should be retrievable somehow :)
W CoderAuthor Commented:
I started another thread on this topic on

The solution turned out to be UIAutomation.

For those who could benefit from the UIAutomation code, it was posted as a response at

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
W CoderAuthor Commented:
It took me literally days of effort trying to get a solution that would work.  Thanks to TnTinMN at and IronRazer at, I was able to get things to work.  Although I'd prefer not to mark my own comment as a solution, I'm sure the info would benefit others if they are faced with a similar problem.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.