How do you simulate input in C #?

I’m thinking about creating several video turnstiles in C #, my problem is that I don’t type very fast, and I don’t want the user to sleep when they watch me type 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 a keyboard.

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

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

Thanks.

+4
source share
4 answers

You have to use SendKeys, I can show you how to use

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

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

what happens if we have a string variable you won’t get anything

If this happens, use it as follows:

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

Hope this works for you.

Yogibear

+3
source

At PDC and other conferences I attended, they use liberal code snippets to quickly add new code.

+1
source

You can use the SendKeys Class

Provides methods for sending keystrokes to an application.

0
source

I'm not sure if you can write to a keyboard buffer or something like this

that I know that it sends some keyboard commands to some windows in your case it will send keyboard commands to notepad, probably in this case use the function above

but I would recommend cutting videos (by typing moments) from your video instead of writing code in C #

0
source

Source: https://habr.com/ru/post/1339227/


All Articles