keybd_event,特殊字符和键盘布局?
我正在开发一个 C# .net 应用程序,允许用户插入文本并让应用程序自动键入文本。它的作用是解析该文本的每个字符并单独发送每个击键。
但是,我想知道是否有办法真正知道输出是什么。例如,
但是,我有点担心特殊字符和键盘布局。
作为参考,我发现此页面包含关键代码: http://msdn.microsoft .com/en-us/library/ms927178.aspx
此页面包含以下几行:
VK_OEM_5 = "\|" for US
VK_OEM_102 = "<>" or "\|" on RT 102-key keyboard
现在,如果我的文本包含“\”,我如何知道是否必须发送 VK_OEM_5 或 VK_OEM_102?
谢谢!
I'm developing a C# .net application that allows users to insert text and have the appliaction automatically type it. What it does is parse every character of this text and send every keystroke seperatly.
However, I am wondering if there's a way to actually know what the output will be. For example,
However, I am a little worried about special characters and keyboard layouts.
For reference, I found this page with the key codes: http://msdn.microsoft.com/en-us/library/ms927178.aspx
This page has the folloing lines:
VK_OEM_5 = "\|" for US
VK_OEM_102 = "<>" or "\|" on RT 102-key keyboard
Now, if my text conains a '\', how do I know if I have to send VK_OEM_5 or VK_OEM_102?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为什么不直接将
WM_CHAR
发送到目标窗口?这适用于大多数程序(通常只有游戏有问题)。这样就可以完全避免键盘布局问题。Why don't you just send
WM_CHAR
s to the target window? This works with most programs(usually only games have problems with it). That way you circumvent the keyboard layout problem completely.考虑到键盘布局,我已经成功使用此代码发送您想要的每个字符(在我的示例中是“%”)。
I've succeeded using this code that sends every char you want (in my sample is '%'), considering the keyboard layout.