向qq聊天窗口的文本框写入字符的方法
苹果13问题由于以前qq消息尾巴病毒的流行,腾讯使用了一些技术,使得现在的qq聊天窗口屏蔽了wm_settext消息
这样的话,要利用程序自动向qq聊天窗口发送文本就比较难了。不过经过测试发现,wm_char消息没有被qq屏蔽。因此,可以使用这个消息把字符发送到聊天窗口。不过要注意的是,发送中文的话,要发送2vivo手机忘记密码怎样开锁次,也就是高低2个字节,不然会乱码的。
Declare Function SendMessage Lib "user32 " Alias "SendMessageA " (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
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
Declare Function GetWindowText Lib "user32 " Alias "GetWindowTextA " (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
这样的话,要利用程序自动向qq聊天窗口发送文本就比较难了。不过经过测试发现,wm_char消息没有被qq屏蔽。因此,可以使用这个消息把字符发送到聊天窗口。不过要注意的是,发送中文的话,要发送2vivo手机忘记密码怎样开锁次,也就是高低2个字节,不然会乱码的。
Declare Function SendMessage Lib "user32 " Alias "SendMessageA " (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
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
Declare Function GetWindowText Lib "user32 " Alias "GetWindowTextA " (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Declare Function PostMessage Lib "user32 " Alias "PostMessageA " (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Declare Function SetWindowText Lib "user32 " Alias "SetWindowTextA " (ByVal hwnd As Long, ByVal lpString As String) As Long
Public Const WM_CHAR = &H102
Public Const WM_SETTEXT = &HC
Public Const WM_LBUTTONDOWN = &H201 口袋妖怪金心图文攻略
Public Const WM_LBUTTONUP = &H202
Public Const BM_CLICK = &HF5
Public Const WM_GETTEXT = &HD
Sub setQQText(ByVal fhwnd As Long, ByVal mystr As String)
Declare Function SetWindowText Lib "user32 " Alias "SetWindowTextA " (ByVal hwnd As Long, ByVal lpString As String) As Long
Public Const WM_CHAR = &H102
Public Const WM_SETTEXT = &HC
Public Const WM_LBUTTONDOWN = &H201 口袋妖怪金心图文攻略
Public Const WM_LBUTTONUP = &H202
Public Const BM_CLICK = &HF5
Public Const WM_GETTEXT = &HD
Sub setQQText(ByVal fhwnd As Long, ByVal mystr As String)
' 向聊天窗口的文本框写入消息。fhwnd 是那个文本框的句柄,来自历史故事的成语mystr 是你要写入的消息
Dim mydata() As Byte, i As Long, tmp_k As Long
i = 0
mydata = StrConv(mystr, vbFromUnicode)
tmp_k = UBound(mydata)
While i <= tmp_k
If mydata(i) < 128 Then
PostMessage fhwnd, WM_CHAR, mydata(i), 0&
i = i + 1
Else
PostMessage fhwnd, WM_CHAR, mydata(i), 0&
PostMessage fhwnd, WM_CHAR, mydata(i + 1), 0&
i = i + 2
End If
Wend
End Sub
顺便再附上几段代码,是关于如何到qq安装程序无法创建新的系统分区那个文本框的句柄的。
Function MyFindWindowEx(wname As String, fhwnd As Long, temphnd As Long) As Long
Dim mystr As String * 255
Do
temphnd = FindWindowEx(fhwnd, temphnd, vbNullString, vbNullString)
GetWindowText temphnd, mystr, Len(mystr) - 1
If InStr(1, mystr, wname) > 0 Then
MyFindWindowEx = temphnd
Exit Function
End Sub
顺便再附上几段代码,是关于如何到qq安装程序无法创建新的系统分区那个文本框的句柄的。
Function MyFindWindowEx(wname As String, fhwnd As Long, temphnd As Long) As Long
Dim mystr As String * 255
Do
temphnd = FindWindowEx(fhwnd, temphnd, vbNullString, vbNullString)
GetWindowText temphnd, mystr, Len(mystr) - 1
If InStr(1, mystr, wname) > 0 Then
MyFindWindowEx = temphnd
Exit Function
Else
MyFindWindowEx = 0
End If
Loop Until temphnd = 0
End Function
先用上面的函数到qq消息窗口的句柄,像这样 qqhwnd=MyFindWindowEx( "聊天中 ",0,0)
再用下面的函数到qq文本输入框的句柄,像这样,传入qq消息窗口的句柄 qqtexthwnd=myFindQQchatText(qqhwnd)
Function myFindQQchatText(ByVal fhwnd As Long) As Long
'获得qq聊天窗口的文本输入框句柄
Dim tmp_hwnd As Long
MyFindWindowEx = 0
End If
Loop Until temphnd = 0
End Function
先用上面的函数到qq消息窗口的句柄,像这样 qqhwnd=MyFindWindowEx( "聊天中 ",0,0)
再用下面的函数到qq文本输入框的句柄,像这样,传入qq消息窗口的句柄 qqtexthwnd=myFindQQchatText(qqhwnd)
Function myFindQQchatText(ByVal fhwnd As Long) As Long
'获得qq聊天窗口的文本输入框句柄
Dim tmp_hwnd As Long
tmp_hwnd = MyCheckWindow(fhwnd, 4)
tmp_hwnd = MyCheckWindow(tmp_hwnd, 23)
tmp_hwnd = MyCheckWindow(tmp_hwnd, 1)
myFindQQchatText = tmp_hwnd
End Function
Function MyCheckWindow(fhwnd As Long, myno As Long) As Long
Dim MyCheck As Long
MyCheckWindow = 0
For MyCheck = 1 To myno
MyCheckWindow = FindWindowEx(fhwnd, MyCheckWindow, vbNullString, vbNullString)
Next
End Function
tmp_hwnd = MyCheckWindow(tmp_hwnd, 23)
tmp_hwnd = MyCheckWindow(tmp_hwnd, 1)
myFindQQchatText = tmp_hwnd
End Function
Function MyCheckWindow(fhwnd As Long, myno As Long) As Long
Dim MyCheck As Long
MyCheckWindow = 0
For MyCheck = 1 To myno
MyCheckWindow = FindWindowEx(fhwnd, MyCheckWindow, vbNullString, vbNullString)
Next
End Function
然后就可以写入消息了。写入消息后,还可以自动按下发送按钮来发送消息
到发送按钮的句柄 qqsendhwnd=myFindQQchatSend(qqhwnd)
Function myFindQQchatSend(ByVal fhwnd As Long) As Long
'获得qq聊天窗口的发送按钮句柄
Dim tmp_hwnd As Long
tmp_hwnd = MyCheckWindow(fhwnd, 4)
tmp_hwnd = MyCheckWindow(tmp_hwnd, 17)
myFindQQchatSend = tmp_hwnd
End Function
再模拟按下发送键 myClickBotton qqsendhwnd
Sub myClickBotton(ByVal fhwnd As Long)
怎样注册商标
到发送按钮的句柄 qqsendhwnd=myFindQQchatSend(qqhwnd)
Function myFindQQchatSend(ByVal fhwnd As Long) As Long
'获得qq聊天窗口的发送按钮句柄
Dim tmp_hwnd As Long
tmp_hwnd = MyCheckWindow(fhwnd, 4)
tmp_hwnd = MyCheckWindow(tmp_hwnd, 17)
myFindQQchatSend = tmp_hwnd
End Function
再模拟按下发送键 myClickBotton qqsendhwnd
Sub myClickBotton(ByVal fhwnd As Long)
怎样注册商标
'按下某个按钮
PostMessage fhwnd, BM_CLICK, 0&, 0&
End Sub
PostMessage fhwnd, BM_CLICK, 0&, 0&
End Sub
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论