简体   繁体   中英

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 to 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

在我参加过的PDC和其他会议上,他们充分利用了代码片段来快速将新代码放入适当的位置。

You could use SendKeys Class

Provides methods for sending keystrokes to an application.

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#

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM