C#发送键盘输入 [英] C# Sending Keyboard Input

查看:95
本文介绍了C#发送键盘输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将键盘输入消息发送到当前选择的窗口或先前选择的窗口?

How can I send keyboard input messages to either the currently selected window or the previously selected window?

我有一个程序可以用来键入键盘上不存在的某些字符,如果我可以直接发送输入而不需要一直复制和粘贴,我会很喜欢.

I have a program which I use to type some characters which are not present on my keyboard and I would like it if I could just send the input directly rather than me having to copy and paste all the time.

此应用程序是键入德国Umlauts.我是美国人,在德国工作.我正在使用美国键盘,有时需要输入变音符号/欧元符号/尖锐的S.目前,我有一个带有文本字段的简单WinForms应用程序,以及一些带有多余字符的按钮.我输入文本字段,然后按按钮将文本追加到文本字段.然后,我复制文本并将其粘贴到任何地方.但是,如果我只要按一下其中一个按钮,它将把文本发送到我正在键入或正在键入的任何地方,那将是很好的.当前程序运行良好,但我可以做得更好.

The application of this is typing the German Umlauts. I'm an American and I work in Germany. I'm working on an American keyboard and from time to time I have to type in the umlauts / the euro symbol / the sharp S. Currently I have a simple WinForms application with a textfield and some buttons with the extra characters on it. I type into the textfield and I can press the buttons to append text to the textfield. I then copy the text and paste it where ever. What would be nice though if I could just just hit one of the buttons and it would send the text where ever I'm typing / was typing. The current program works fairly well but I could make it better.

推荐答案

SendKeys.Send 可以帮助您.

这篇关于C#发送键盘输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆