如何录制键入C#(的KeyListener) [英] How to record typing in C# (keyListener)

查看:148
本文介绍了如何录制键入C#(的KeyListener)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想编写一个简单的文本语音程序。

I want to write a simple text to speech program.

首先,我想使程序只能起到书写符号。例如,如果我输入a我希望该计划说'一'(我记录了所有的),所以当我输入一个字,就应该拼一下。

First, I want to make the program play only the written symbol. For example, if I type 'a' I want the program to say 'a' (I have recorded all of them), so when I type a word, it should spell it.

不过,我在C#和.NET一个初学者,没怎么让程序知道我键入的文本。例如,在java中我听说有一个的KeyListener类,但我不知道我应该使用哪一个类。我看了看MSDN上也没有找到它。

However, I am a beginner in C# and .Net and don't how to make the program understand the text I type. For example, in java I heard that there is a keyListener class, but I don't know which class should I use. I looked on MSDN but couldn't find it.

我应该使用哪种类或函数来听类型的钥匙?

Which class or function should I use to listen to typed keys?

推荐答案

我想你计划使用Windows窗体来实现这一目标。 该解决方案将是pretty的简单。这些事件包括的MouseDown,的MouseUp,的MouseMove,的MouseEnter,鼠标离开,MouseHover,重点preSS,KeyDown和的KeyUp。每个控件都有这些事件暴露出来。你只需要申请开通该服务。

I suppose you are planning to use Windows Forms to achieve this. The solution would be pretty simple. These events include MouseDown, MouseUp, MouseMove, MouseEnter, MouseLeave, MouseHover, KeyPress, KeyDown, and KeyUp. Each control has these events exposed. You just need to subscribe to it.

请参阅本 <一href="http://msdn.microsoft.com/en-us/library/system.windows.forms.control.keydown.aspx">http://msdn.microsoft.com/en-us/library/system.windows.forms.control.keydown.aspx

将会有逻辑的一点点找到一个完整的字是否已经输入与否。一个简单的soultion是,当空间已经pressed,你可以假设一个字已经完成。它非常粗略的逻辑,因为用户可能输入错误的拼写和希望打退格键和纠正拼写。您可能要添加滞后了。

There would be a little bit of logic to find whether a complete word has been typed or not. A simple soultion would be , when space has been pressed, you can assume a word has been completed. Its very crude logic, as the user may have typed in wrong spelling and want hit backspace and correct the spelling. You may want to add lag to it.

这篇关于如何录制键入C#(的KeyListener)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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