How can you simulate keyboard key presses so that, for example, by running the corresponding script, the specified text itself is typed in a third-party program? However, it is more interested in emulating keyboard shortcuts, and not character or digital, but such as CTRL or SHIFT. Cross-platform is not important.

  • There was a SendKeys module that easily allowed special keys to use. I don’t know if it works in Python 3. Here’s an example of use (at the end of the answer . - jfs
  • The problem is that through pip3 install sendkeys it is not installed, it falls with errors, not excluded at all! - Constantor
  • quite possibly. The module is ancient and its main (variant) advantage was simplicity and lack of dependencies except ctypes (I can’t find the source now, here’s an example of how it could look ). pywinauto is a less simple module that also SendInput() API. The only drawback of pyautogui in comparison with SendKeys is that the pillow is an addiction, as well as some advantages: it is also simple, but portable, and supports not only the keys. - jfs

1 answer 1

The pyautogui module helped (a little about it here ). Unfortunately it does not support the Cyrillic alphabet, but in my case this is not a problem.