用VB能不能得到QQ聊天窗口里的对话内容?

2024年12月03日 01:54
有3个网友回答
网友(1):

qq2008 下测试可用。

===================================================

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
Private Declare Function SendMessageByString Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) As Long
Private Const WM_GETTEXT = &HD
Private Const WM_GETTEXTLENGTH = &HE

'以下是查找窗口 RichEdit20A 的代码:
Private Function MyFindWindow(ByVal title As String) As Long
'父窗口类名数组
Dim A_szClassName(3) As String
A_szClassName(0) = "#32770"
A_szClassName(1) = "#32770"
A_szClassName(2) = "RichEdit20A"
'父窗口标题数组
Dim A_szWinName(3) As String
A_szWinName(0) = title
A_szWinName(1) = ""
A_szWinName(2) = ""
'首先求得顶级父窗口
Dim hLastWin As Long
hLastWin = FindWindow(A_szClassName(0), A_szWinName(0))
'逐次用FindWindowEx函数求出各级子窗口
For i = 1 To 2
hLastWin = FindWindowEx(hLastWin, 0, A_szClassName(i), A_szWinName(i))
Next i
MyFindWindow = hLastWin
End Function
'举例: Dim hLastWin as Long
' hLastWin = MyFindWindow()

Private Function GetText(WindowHandle As Long) As String
Dim buffer As String, TextLength As Long
TextLength& = SendMessage(WindowHandle&, WM_GETTEXTLENGTH, 0&, 0&)
buffer$ = String(TextLength&, 0&)
Call SendMessageByString(WindowHandle&, WM_GETTEXT, TextLength& + 1, buffer$)
GetText$ = buffer$
End Function

Private Sub Command1_Click()
MsgBox GetText(MyFindWindow("与 haokeyy 交谈中"))
End Sub

在MyFindWindow函数的参数内写上QQ聊天窗口的标题即可,点击按钮command1后将显示聊天窗口内的聊天记录。

网友(2):

不行!

网友(3):

现在都加密,难做