如何使用西里尔字符发送键盘消息事件
我想模拟键盘点击并用西里尔语键入某些消息。 我知道如何模拟键盘事件:
SendKeyboardMessage(handle, WM_KEYDOWN, Convert.ToInt32(key), 0);
SendKeyboardMessage(handle, WM_KEYUP, Convert.ToInt32(key), 0);
但第三个参数是“Keys”类型并且没有西里尔字符。
那么如何使用西里尔字符发送键盘事件呢?
将消息发送到应用程序本身而不是全局的很重要
i want to simulate keyboard clicks and to type certain message in Cyrillic.
i know how to simulate keyboard event:
SendKeyboardMessage(handle, WM_KEYDOWN, Convert.ToInt32(key), 0);
SendKeyboardMessage(handle, WM_KEYUP, Convert.ToInt32(key), 0);
but the 3rd argument is "Keys" type and there is no Cyrillic char.
So how to send keyboard event with Cyrillic chars?
Its important to send the message to the application it self NOT global
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
也许尝试先将键盘布局更改为西里尔文,然后模拟键盘事件。
我发现此代码项目展示了如何更改布局。
希望有帮助
Maybe try and change the keyboard layout first to Cyrillic and then simulate the keyboard events.
I found this code project that shows how you can change the layout.
Hope that helps
相同的功能也适用于西里尔语。
您了解 KEY 和 CHARACTER 之间的区别吗?键在键盘上,而字符是在屏幕上绘制的内容。 WM_KEYDOWN 和 WM_KEYUP 不发送字符,而是发送按键。
Keys
数据类型涵盖了作为硬件的键盘 - 无论它们在您的本地语言中意味着什么,您总是有相同的 102 个左右的键。这些键稍后会使用活动代码页转换为字符。因此,这就是为什么您可以对西里尔语使用相同的功能,只需将活动代码页切换到西里尔语并发送正确的键名称,就像从使用英语键盘一样。The same function should work for Cyrilic as well.
Do you understand the difference between KEY and CHARACTER? Keys are on your keyboard, while characters are what is drawn on screen. WM_KEYDOWN and WM_KEYUP don't send characters, they send keys.
Keys
datatype covers keyboard as a hardware - you always have the same 102 or so keys there regardless of what they mean in your local language. These keys are converted to characters later, using active code page. So that's why you can use the same function for Cyrilic, just switch active code page to Cyrilic and send the right key names as if it was from an u.s.english keyboard.