VB 发送单击按钮问题 帮我看看代码哪错了

PrivateDeclareFunctionFindWindowLib"user32"Alias"FindWindowA"(ByVallpClassNameAsStrin... Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName 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)
Private Const WM_RBUTTONDOWN As Long = &H201
Private Const WM_RBUTTONUP As Long = &H202
Const MK_LBUTTON = &H1
Private Sub Command1_Click()
Dim hwnd As Long, A As Long
Dim lParam As Long
lParam = (198 * &H10000) Or 279
hwnd = FindWindow("TXGuiFoundation", "QQ2010")
SendMessage hwnd, WM_LBUTTONDOWN, 0, ByVal lParam
SendMessage hwnd, WM_LBUTTONUP, 0, ByVal lParam
Text1.Text = Val(A)
End Sub
老发送不出
用delphi又能行
试过很多办法都不成功
PostMessage 方法不行
目的是单击按钮 QQ自动登录
登陆的那个按钮跟主窗口 是同一个..
简单点说登陆的那个按钮 不是子窗口
展开
 我来答
hmlky
2010-06-01 · TA获得超过1369个赞
知道小有建树答主
回答量:239
采纳率:0%
帮助的人:362万
展开全部
哈哈,调试成功了!!!!

Option Explicit
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName 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)
Private Declare Function SetFocusAPI& Lib "user32" Alias "SetFocus" (ByVal hwnd As Long)
Private Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long
'这里你定义差了,你定义的是WM_RBUTTONDOWN和备腊WM_RBUTTONUP
Private Const WM_LBUTTONDOWN = &H201
Private Const WM_LBUTTONUP = &H202
Private Sub Command1_Click()
Dim hwnd As Long, a As Long
Dim lParam As Long
lParam = (210 * &H10000) Or 279
hwnd = FindWindow("仿禅滑TXGuiFoundation", "QQ2009 Beta2")
'这里我给该成QQ2009了,我用的是QQ2009
Debug.Print hwnd
SetForegroundWindow hwnd
SetFocusAPI hwnd
SendMessage hwnd, WM_LBUTTONDOWN, 0, ByVal lParam
SendMessage hwnd, WM_LBUTTONUP, 0, ByVal lParam
End Sub
=====================================================================
真是对不起,
我们初中作业多,有空我给你好好想想。
=====================================================================
我管你叫大哥了。
FindWindow找到的是主窗口的句柄,
应该用FindWindowEx获得控件句柄再SendMessage。
=====================================================================
你调试一下,看看hwnd是不是为0,没有获取到袭祥。
你程序的目的是不是将其窗口激活?
你可以用
Private Declare Function SetForegroundWindow Lib "user32" Alias "SetForegroundWindow" (ByVal hwnd As Long) As Long
试试
要不再试试用
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
代替SendMessage

lParam传入的是鼠标的坐标,你求出它是固定的?
用GetWindowRect获取窗口的坐标再将其传入试试。
=====================================================================
QQ2010的界面
嗯,
我曾经用 HOOK 拦截过消息,结果能拦截键盘输入,却是一堆乱码。
可能不成功的原因是QQ没有用窗口回调函数,
所以消息没有插入消息队列,它也不从消息队列中读取消息。

这是SendMessage的说明:

该函数将指定的消息发送到一个或多个窗口。此函数为指定的窗口调用窗口程序,直到窗口程序处理完消息再返回。

也可能是对消息进行了加密,比如说
它的WM_LBUTTONDOWN=WM_USER+1
书西靠可暴2h
2010-05-30 · TA获得超过487个赞
知道小有建树答主
回答量:367
采纳率:0%
帮助的人:214万
展开全部
你可以档薯森把hwnd = FindWindow("TXGuiFoundation", "手差QQ2010")
改成行亩hwnd = FindWindow("TXGuiFoundation", instr"QQ2010")
试一下,我在网吧无法测试
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

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

类别

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

说明

0/200

提交
取消

辅 助

模 式