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)) '得到聊天窗口标题~
If InStr(TheWindow_Title, "聊天中") = 0 Then
Exit Sub
Else
TextObj = FindWindowEx(TheWindow, 0, "#32770", vbNullString) '通用对话框的类
If TextObj = 0 Then Exit Sub
TextObj = FindWindowEx(TextObj, 0, "RichEdit20A", vbNullString) '聊天框的类
If TextObj = 0 Then Exit Sub
Text1.Text = SendMessage(TextObj, WM_GETTEXT, 0, 0)
End If
End Sub
打开QQ,进行聊天模式,和网友聊天,程序自动获得聊天记录,但是...前面都正确了,但是就是得不到内容...急了...大家帮帮忙啊~~~~~
[此贴子已经被作者于2006-11-17 18:23:14编辑过]