findwindow text

Go To StackoverFlow.com

1

Hey all i am trying to get some text form an external program. Currently i am using this code:

Dim lngHWND As Long
Dim lngHWNDF As Long
Dim lngID As Long
Dim lngChild As Long
Dim lngRet As Long

lngHWND = FindWindow(vbNullString, "Client - Main")

Do
   lngChild = FindWindowEx(lngHWND, 0&, "ThunderRT6Frame", vbNullString)

   If lngChild <> 0 Then
        lngID = GetWindowLong(lngChild, GWL_ID)
        MsgBox("Child HWND: " & Hex(lngChild) & " ID: " & lngID)
        lngRet = CloseHandle(lngChild)
   End If
Loop Until lngChild = 0

lngRet = CloseHandle(lngHWNDF)
lngRet = CloseHandle(lngHWND)

I am getting values for both the lngHWND, lngHWNDF and the lngChild. However, they are only values (numbers) and not the text itself.

Here is an image of the program i am trying to get the text from: the prog

How can i go about getting the text from those items it finds?

David

2012-04-04 22:16
by StealthRT


0

Its literally been over a decade but I'm pretty sure you can use SendMessage/WM_GETTEXT to the handle(s) of the child windows you want the text of. You'll have to prepare string buffers that the API can write the results into if you go this route.

There also appears to be a shortcut to using SendMessage/WM_GETTEXT I found here:

Public Declare Ansi Function GetWindowText Lib "User32.dll" Alias "GetWindowTextA" ( _
    ByVal hwnd As Integer, _
    ByVal lpString As StringBuilder, _
    ByVal nMaxCount As Integer) As Integer

' example:
Dim s As New StringBuilder(256)
GetWindowText(hwnd, s, s.Capacity)
2012-04-04 22:34
by cfeduke
Ads