1,451
社区成员
发帖
与我相关
我的任务
分享
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 hWndParent As Long, ByVal hWndChildAfter As Long, ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Private Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Private Sub Command1_Click()
Dim hWndMSG&, lTemp&, i&, strOut$
'你在用的时候,把这‘记事本’换成你实际的消息框标题.
hWndMSG = FindWindow("#32770", "记事本")
If (hWndMSG = 0) Then MsgBox "没有找到消息框!", 48, "查找窗口": Exit Sub
lTemp = 0
Do
lTemp = FindWindowEx(hWndMSG, lTemp, vbNullString, vbNullString)
If (lTemp > 0) Then If ((GetWindowLong(lTemp, -16&) And 128&) = 128&) Then Exit Do
Loop While (lTemp > 0)
If (lTemp = 0) Then MsgBox "没有找到消息内容窗口!", 48, "查找窗口": Exit Sub
i = GetWindowTextLength(lTemp) + 1
strOut = String(i, vbNullChar)
GetWindowText lTemp, strOut, i
MsgBox strOut, 64, "找到的消息内容"
End Sub