开发者

Virtual keyboard in C#

I want to write an application that send various ke开发者_如何学Pythonycodes depending on which button the user clicked. How would I send the keycodes? For example, how to emulate the 'a' press? How about modifier keys?


This gets asked every single day:

How to simulate key presses in C#

Simulating Key Press c#

Keypress To Simulate A Button Click in C#

How to simulate keypress


Once you have got the sending of key presses to another window sorted out, you are going to face another problem. That is when the user clicks the button on your virtual keyboard the target window, the one you want to have receive the key press, will loose focus and the SendKeys will not seem to work.

There many solutions to this problem, but the quick and dirty solution that requires minimal effort is to change the style of your virtual keyboard window to include WS_EX_NOACTIVATE

See the answer I provided to the following question HERE for Windows Forms and if you want to do this using WPF I have a similar answer HERE

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜