怎么样利用VB给打开的QQ窗口发送信息

 我来答
一念春风十里不如你
2016-12-04 · TA获得超过1536个赞
知道小有建树答主
回答量:2560
采纳率:68%
帮助的人:298万
展开全部
Declare Function FindWindowExA Lib "user32" (ByVal Hwnd1 As Long, ByVal Hwnd2 As Long, _
ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Declare Function SendMessageA Lib "user32" (ByVal Hwnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, lParam As Any) As Long
Declare Function GetWindowTextA Lib "user32" (ByVal Hwnd As Long, ByVal lpString As String, _
ByVal cch As Long) As Long
Const EM_REPLACESEL = &HC2
Const BM_CLICK = &HF5

Sub Test()
Dim Hwnd As Long
Dim Title As String
Hwnd = FindWindowExA(0, 0, "#32770", vbNullString)
Do While Hwnd > 0
Hwnd = FindWindowExA(0&, Hwnd, "#32770", vbNullString)
Title = Space(255)
GetWindowTextA Hwnd, Title, 256
If (Title Like "*聊天中*") Or (Title Like "*群*") Or (Title Like "*会话中*") Then
SendMsg Hwnd, "QQ消息群发"
End If
Loop
End Sub

Function SendMsg(Hwnd As Long, Meg As String)
Dim Hwnd1 As Long
Dim Hwnd2 As Long
Hwnd1 = FindWindowExA(Hwnd, 0, "#32770", vbNullString)
Hwnd2 = FindWindowExA(Hwnd1, 0, "Button", "发送(S)")
Hwnd1 = FindWindowExA(Hwnd1, Hwnd2, "AfxWnd42", vbNullString)
Hwnd1 = FindWindowExA(Hwnd1, 0, "RichEdit", vbNullString)

SendMessageA Hwnd1, EM_REPLACESEL, 0, ByVal Meg
SendMessageA Hwnd2, BM_CLICK, 0, ByVal 0
End Function
本回答被网友采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式