如何使用全局键盘挂钩发送键? [英] How do i send keys using a global keyboard hook?
问题描述
我正在尝试将密钥发送到一个应用程序,该应用程序不响应我到目前为止使用的任何API(SendInput(),PostMessage(),SendMessage()等).但是,我测试了Windows的屏幕键盘实用程序",然后按了所需的键,应用程序很容易收到了这些键.
I'm trying to send keys to an application which does not respond to any of the API's that I have so far used (SendInput(), PostMessage(), SendMessage() and others). However, i tested Windows' On-Screen Keyboard Utility and pressed the keys i needed and the application received these keys easily.
如果我正确理解键盘实用程序使用全局键盘钩子来发送键的话,那么我很感兴趣如何实现这一点.我曾尝试找到如何在Google上完成此操作的示例,但没有结果.
If i understand correctly the keyboard utility uses global keyboard hooks to send the keys, so I'm interested i how i could do so as well. I have tried finding examples of how this can be done on google but have come up with no results.
谢谢.
推荐答案
我解决了.我正在将密钥发送到DirectX应用程序.原来我不得不发送DirectX扫描代码,而不是常规的VK_KEY.
I solved it. I was sending keys to a DirectX application. Turns out i had to send DirectX scan codes instead of regular VK_KEY's.
可以在以下位置找到扫描代码列表: http://www.gamespp.com/directx/directInputKeyboardScanCodes.html
A list of scan codes can be found at: http://www.gamespp.com/directx/directInputKeyboardScanCodes.html
将它们与SendInput()结合使用,一切都很好.
Using these with SendInput() and everything worked great.
也感谢您的帮助.
干杯.
这篇关于如何使用全局键盘挂钩发送键?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!