谢谢..13楼的兄弟....
现在能成功得到了...我将源码全部发出来.....人人为我,我为人人!
Private Declare Function GetForegroundWindow Lib "user32" () 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 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)
'Private Const WM_GETTEXT = &H7D
Private Const WM_GETTEXT = &HD
Private Const WM_GETTEXTLENGTH = &HE
Private Sub Form_Load()
Timer1.Interval = 1000
End Sub
Private Sub Timer1_Timer()
On Error Resume Next
Dim sText As String * 255
Dim TextObj As Long
Dim txtLendth As Long, txtBuff As String
TheWindow = GetForegroundWindow '获得当前窗口句柄
If TheWindow = 0 Then Exit Sub
thewindow_title = Left$(sText, GetWindowText(TheWindow, sText, 255)) '得到聊天窗口标题~
chatobj = thewindow_title
'Debug.Print thewindow_title
If InStr(thewindow_title, "聊天中") <> 0 Or InStr(thewindow_title, "- 群") <> 0 Or InStr(thewindow_title, "查看消息") <> 0 Then
TextObj = FindWindowEx(TheWindow, 0, "#32770", vbNullString) '通用对话框的类
If TextObj = 0 Then Exit Sub
TextObj = FindWindowEx(TextObj, 0, "RichEdit20A", vbNullString) '聊天框的类
If TextObj = 0 Then Exit Sub
txtLength = SendMessage(TextObj, WM_GETTEXTLENGTH, ByVal CLng(0), ByVal CLng(0))
txtBuff = Space(txtLength)
retVal = SendMessage(TextObj, 13, ByVal txtLength + 1, ByVal txtBuff)
Text1 = Left(txtBuff, retVal) & vbCrLf & vbCrLf & "以上聊天对象为:" & chatobj
Else
Exit Sub
End If
End Sub
不顶用么!!!