0

I am new to ubuntu and I am trying to recreate some projects I made in Windows and I have a problem with simulated keystrokes and simulated mouse movement and clicks.

So lets say I want to do something like pyautogui.press('a') or an alternative without using python would be to type in the terminal xdotool key a, the idea is simply to simulate the press of the letter a, and what happens is that it detects the keystroke, but depending on which program I am using it doesn't take it as an input. For example if I try to run that in the normal terminal it won't show as if I pressed the letter a, but if I run the command in visual studio or sublime text it works perfectly fine. It also seems that it has problems interacting between windows, using shortcuts and simulating mouse events.

Sincerely I just want to know if it is a feature that protects the system from unwanted simulated keystrokes or it's just something I'm doing wrong, because I couldn't find any information online about the topic.

1 Answers1

1

The reason it does not work is because you are using the new Wayland display protocol. Tools like xdotool and pyautogui only work in Xorg.

You can run Ubuntu on Xorg. Under Wayland, a tool ydotool that allows to simulate keystrokes in Wayland is under developement. The version in the repository of Ubuntu 22.04 is older and does not actually work. You can, however, compile a more recent version quite easily. I am currently not aware of the development or existence of Python libraries that would provide the functionality of pyautogui on Wayland.

vanadium
  • 88,010