我必须为我们公司的程序编写一个屏幕键盘,该程序主要用于具有触摸功能的工业PC。
我们不能使用windows默认键盘,因为我们不需要键盘上的所有按键。所以我被要求用 C# 编写一个自定义的。
我已经找到了这个博客 http://www.siao2.com/2006/04/22/581107.aspx作为参考,但我不知道如何开始。
我创建了一个小型原型 GUI,并为每个键分配一个扫描码,并将这些扫描码转换为相关字符。并将它们发送到主动控制。但我不确定应该使用什么扫描码。
所以我的问题是,这是编写这样的 OSK 的正确方法吗?如果是,我应该使用哪些扫描码?有链接吗?
I'm also not sure how to handle the shift states...
Edit:
Okay I did a bit more research and came up with a osk which reads the current keyboard layout and even handles the easy shift states (Shift and Alt Gr). I wrote a KeyButton
class which inherits from Button
, this KeyButton
has a ScanCode
property of type byte and if you assign a valid scancode to it, the KeyButton
will call the related functions to get the correct text. I used the functions from Michael Kaplan blogs with some small changes. In the end it turned out that I just had to do the same as he did.
所以我的问题的答案是:是的,您必须在按钮上使用扫描代码,然后从键盘布局中获取虚拟键和 unicode。使用这些扫描码。 http://www.win.tue.nl/~aeb/linux/kbd/scancodes-1.html
现在我得到了角色,唯一剩下的就是将它们发送出去。
我认为这相当简单,只需制作一系列按钮并为每个按钮分配一个字母,然后在按钮的 Click 方法内部就可以做一个简单的事情。
SendKeys.Send("A");
根据按钮等更改键
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)