Option Explicit
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
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
Const WM_GETTEXT = &HD
Const WM_GETTEXTLENGTH = &HE
Dim Phwnd&, ChildHwnd&, Tmpstr$, Textlen&
Private Sub Command1_Click()
Phwnd = FindWindow(vbNullString, "隔岸观火")
If Phwnd <> 0 Then
ChildHwnd = FindWindowEx(Phwnd, 0, "ThunderTextBox", vbNullString)
If ChildHwnd > 0 Then
MsgBox GetText(ChildHwnd)
End If
End If
End Sub
Function GetText(Thwnd As Long) As String
Textlen = SendMessage(Thwnd, WM_GETTEXTLENGTH, 0, 0)
If Textlen = 0 Then GetText = "": Exit Function
Textlen = Textlen + 1
Tmpstr = Space(Textlen)
Textlen = SendMessage(Thwnd, WM_GETTEXT, Textlen, ByVal Tmpstr)
GetText = Left(Tmpstr, Textlen)
End Function