更改通过钩子的击键(c/c++)
是否可以使用 winapi 键盘挂钩编辑击键?好吧,不需要键盘挂钩,而是类似的东西..
我想做这样的事情:
用户按下键“A”,
我的函数将 1 添加到虚拟键码(只是一个例子),
“A”变成“B”
,然后“B”已发送至目标应用程序,
谢谢!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
首先,您需要一个Keyboardhook。您安装一个过滤器,过滤器函数接收虚拟键代码和键盘挂钩时键盘的状态。然后您可以更改虚拟键代码。
其他链接:
http://msdn.microsoft.com/ en-us/library/ms644990(VS.85).aspx
http://msdn.microsoft.com/en-us/library/ms644984(VS.85).aspx
First, you need a Keyboardhook. You install a filter and the filter function receives the virtual-key code and the state of the keyboard at the time of the keyboard hook. Then you can change the virtual-key code.
Additional Links:
http://msdn.microsoft.com/en-us/library/ms644990(VS.85).aspx
http://msdn.microsoft.com/en-us/library/ms644984(VS.85).aspx
我认为你可以通过应用键盘钩子消耗用户输入的击键来做到这一点。
并生成你想要的角色的key_event。
I think you can do it by eating up the keystroke entered by user by applying keyboard hook.
and generating key_event of the character you want.
您无法直接更改 KBDLLHOOKSTRUCT 中的虚拟键值。
相反,在使用修改后的虚拟键值发送消息后,在挂钩函数中返回 1。
You can't change the virtual key value in the KBDLLHOOKSTRUCT directly.
Instead, return 1 in the hook function after you sendmessage with your modified virtual key value.