Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to simulate keyboard input in ALL applications?

I'm writing an app (in C#) which as a part of it must simulate and send some key strokes to another application. I'm using http://inputsimulator.codeplex.com/ project for simulating keys, and it works in many applications, but in some it doesn't - i.e. Mortal Combat 4.

I've googled about it, and found many answers varying from 'it's impossible' to 'you must use XXX library' etc. Those answered scared me a lot, and even nearly convinced I'm not able to do it at that time, BUT...

M$ Virtual Keyboard works. It works in ALL applications. So it IS possible... Does anyone of you, clever guys, know how can I achieve this?

like image 319
Fenix Voltres Avatar asked Jan 06 '12 15:01

Fenix Voltres


People also ask

How do you simulate keystrokes?

To simulate native-language keystrokes, you can also use the [Xnn] or [Dnn] constants in the string passed to the Keys method. nn specifies the virtual-key code of the key to be “pressed”. For instance, [X221]u[X221]e will “type” the u and e characters with the circumflex accent.

Can Python simulate keypress?

This demonstrates how to press keys with Python. Using pynput we are able to simulate key presses into any window. This will show you how to press and release a key, type special keys and type a sentence.

How do you simulate mouse and keyboard events in code?

The best way to simulate mouse events is to call the On EventName method that raises the mouse event you want to simulate. This option is usually possible only within custom controls and forms, because the methods that raise events are protected and cannot be accessed outside the control or form.

Which command is used to simulate a user pressing and releasing a key?

KeyDown and Desktop. KeyUp - simulate pressing and releasing the specified key by its virtual code.


1 Answers

Ok, I think I finally got it to work. I used API Monitor recommended by Neal P and it showed just minimal differences between OSK calls and mine. A bit later I've tried to make my calling thread sleep some time between sending messages with press and release key and that was it.

like image 115
Fenix Voltres Avatar answered Oct 10 '22 13:10

Fenix Voltres