模拟鼠标单击问题
我是先取得窗口句柄,再取得按钮句柄,想要鼠标单击一下这个按钮!但是用SENDMESSAGE和POSTMESSAGE总是不成功,在网上找了半天还是不行,就懒得找了,来这时问下算了,
sendmessage(handle,wm_lbuttondown,0,0)
sendmessage(handle,wm_lbuttonup,0,0)不行,在二个0后加个& 也不行
用POSTMESSAGE,
PostMessage handle,wm_lbuttondown,0&,0&
PostMessage handle,wm_lbuttonup,0&,0&
也不行,在网上打的全是后面加X加Y的,我想要个不加X,Y就行的句子
[解决办法]
Option ExplicitConst MK_LBUTTON = 1'http://topic.csdn.net/u/20100312/09/bd98168f-038a-45a5-97c7-00b9b08f94de.html?seed=452989452&r=63867885#r_63867885'发鼠标消息还是用PostMessage吧Private Sub Command1_Click()Dim hpwnd As Long, hcwnd As Long, iresult As Longhpwnd = FindWindow(vbNullString, "12345")hcwnd = FindWindowEx(hpwnd, 0, vbNullString, "确定")SetForegroundWindow hcwndiresult = PostMessage(hcwnd, WM_LBUTTONDOWN, ByVal MK_LBUTTON, ByVal 0&)iresult = PostMessage(hcwnd, WM_LBUTTONUP, ByVal 0&, ByVal 0&)End Sub
[解决办法]
貌似鼠标键盘消息只能使用PostMessage进行投递,而不能强行让目标消息循环直接处理(SendMessage)