开发者

How Do You Simulate Typing in c#?

I am thinking of making a few video turorials on C#, my problem is that I don't type very fast and I don't want to put the user to sleep as they watch me typing in real-time.

I would like to write a small C# program that will take a line of text and feed it t开发者_开发知识库o the keyboard buffer, so that I can simulate keyboard typing.

Does anyone know how to access the keboard buffer to do this?

If this has been done before or if someone knows of an existing program to do this, can you point me in the right direction.

Thanks.


You should use SendKeys, i can show you how to use

here is an example: SendKeys.Send('A');

but u can use it with your own character: SendKeys.Send(CHARACTER HERE);

what happens if we have a string variable, you will get nothing

if it happens use it this way:

string letter = "exampleletter";
foreach (char ch in letter) 
   SendKeys.Send(ch.ToString());

i hope it works for you

Yogibear


At PDC and other conferences I've been at, they make liberal use of code snippets to quickly drop the new code into place.


I'm not really sure that you can write to keyboardbuffer or something like this

what I know it to send to some windows some keyboard commands in your case it will be sending keyboard commands to notepad probably in that case use the function provided above

but I would recommend to cut video parts (typing moments) out of your video instead of writing code in C#


You could use SendKeys Class

Provides methods for sending keystrokes to an application.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜