使用虚拟键码模拟鼠标按钮 [英] Simulate mouse button by use Virtual Key Codes

查看:99
本文介绍了使用虚拟键码模拟鼠标按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有问题:
我想通过使用虚拟按键代码来模拟鼠标按钮

I have a problem:
I want to Simulate mouse button by use Virtual Key Codes

Public Declare Function SetActiveWindow Lib "user32" Alias "SetActiveWindow" _
(ByVal hwnd As Long) As Long
Declare Function keybd_event Lib "user32" Alias "keybd_event" _
(ByVal bVk As Byte, ByVal bScan _
As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long) As Long





Const VK_LBUTTON = &H1



当我打电话给我时:



And when i call:

SetActiveWindow(8975651603260375040)
keybd_event(VK_LBUTTON, 0, 0, 0)
keybd_event(VK_LBUTTON, 0, KEYEVENTF_KEYUP, 0)



=>>不工作
请帮助我!:confused:



=>>NOT WORK
Please help me!:confused:

推荐答案

我一直在研究这个问题,尝试了各种尝试,但是却得到了同样的结果.我已经在API文档中注意到,在较新的OS中,keybd_event已被SendInput取代.我什至用较新的API编写了一些代码,但仍然无法正常工作.不会打败我的.

同时,您可能想尝试使用SendInput.请参阅MSDN上的参考以及这两个链接;

http://www.pinvoke.net/default.aspx/user32.SendInput [ ^ ]

http://forums.devx.com/archive/index.php/t-84391.html [^ ]
I have been looking at this, and trying various things, but get the same thing. I have noticed in the API docs that keybd_event has been replaced by SendInput in the newer OS''s. I have even written some code with the newer API and it still doesn''t work. It won''t beat me.

In the mean time, you may want to have a try using SendInput. See the references on MSDN and these two links;

http://www.pinvoke.net/default.aspx/user32.SendInput[^]

http://forums.devx.com/archive/index.php/t-84391.html[^]


这篇关于使用虚拟键码模拟鼠标按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆