怎么样利用VB给打开的QQ窗口发送信息
1个回答
展开全部
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
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
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询