求助这段代码有什么问题么?
求助高手,我想实现的功能,是单击后,程序能自动把这段文字复制到旺旺的聊天对话框中,
"中华人民共和国 Chinese"
旺旺的聊天对话框标题是:米朵 - xi1117
写了这段代码,但是点击后没反应,求助高手是哪里出问题了么?
Option Explicit
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 Any, ByVal lpsz1 As Any, ByVal lpsz2 As String) As Long
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) 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 Const WM_SETTEXT = &HC&
Private Sub Command1_Click()
Dim hWndWindow As Long
Dim hWndEdit As Long
hWndWindow = FindWindow(vbNullString, "米朵 - xi1117")
hWndEdit = FindWindowEx(hWndWindow, vbNullString, "edit", vbNullString)
SendMessage hWndEdit, WM_SETTEXT, 0, ByVal "中华人民共和国 Chinese"
End Sub
[解决办法]
你要用FindWindowEx来查找多次,才能找到输入内容对话框,你可以用SPY++来辅助一下,看看自己的代码是否找对句柄