S
S
sergeevpetro2018-11-02 22:42:34
C++ / C#
sergeevpetro, 2018-11-02 22:42:34

How to simulate a key press in a game?

I decided to remember my youth and play Lineage 2, but I wanted to speed up the process of catching up with top players and write a small bot for farming (resource extraction).
Started from the very beginning - emulation of keystrokes. I've already tried enough options and variations to get fucked up.
What have you tried?
SendKeys, InputSimulator, SendMessage and PostMessage via hwnd windows.
Ideas run out. Please help!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
GavriKos, 2018-11-02
@GavriKos

Your keyboard driver - that's it.
I think that in Lineage, due to her age, there are more defenses than dofiga against simple bots.

V
VoidVolker, 2018-11-03
@VoidVolker

There is also DirectInput for DirectX games. For OpenGL games and everything else that does not accept the previous options, you need to write your own driver, which will be in the zero ring and which will either write data directly to the keyboard buffer or pretend to be a driver itself. And in newfangled and modern Windows, the driver must also be signed - otherwise it will not work. In XP and below, it seems easier to do. If I remember everything correctly, of course, how it's all done. Try looking for a ready-made template or an example keyboard/mouse driver.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question