Game does not recognize keyboard input by "pynput"

Asked

Viewed 35 times

1

I’m creating a bot to press the "A" key inside a game.

Code I am using:

from pynput.keyboard import Controller;
from time import sleep;

keyboard = Controller();

sleep(2)

keyboard.press("a");
keyboard.release("a");

In the notepad the script works well, press the key smoothly.

However, inside the game does not work. It does not simulate the desired key.

I did some research and apparently it has to do with the focus of the system. How do I solve?

  • Script/Bot does not break game rules?

1 answer

1

These are game security mechanisms, most can differentiate real inputs from script inputs.

The following video has an explanation of why input by "pyautogui" did not work in his game, but the same concept applies to "Keyboard". The video is in English (Video "Pyautogui not Working? Use Directinput")

In the case he suggested using the Pydirectinput to make mouse and keyboard inputs in a way that games interpret as a native input. But still, be aware that game developers are always looking for ways not to recognize script entries, and be careful not to hurt the rules of the game itself.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.