无法将鼠标与 xdotool 等自动化应用程序一起使用

无法将鼠标与 xdotool 等自动化应用程序一起使用

因此,我只是在我的 PC 上安装了 Ubuntu 作为与 Windows 10 的双启动系统。我在上面安装了 xdotool 并继续使用它。我尝试了“xdotool mousemove 0 0”但什么也没发生。我的鼠标没有移动,xdotool 没有显示任何输出。后来我尝试使用 pynput 和 python 来做我想做的事情,但它也失败了。它没有显示任何输出,我的鼠标光标也没有移动。我没有看到任何错误。我还尝试以 root 身份使用该脚本,然后显示此错误:

  File "/home/skzafir/Documents/Python/Test/mouse.py", line 1, in <module>
    from pynput.mouse import Controller, Button
  File "/usr/local/lib/python3.9/dist-packages/pynput/__init__.py", line 40, in <module>
    from . import keyboard
  File "/usr/local/lib/python3.9/dist-packages/pynput/keyboard/__init__.py", line 31, in <module>
    backend = backend(__name__)
  File "/usr/local/lib/python3.9/dist-packages/pynput/_util/__init__.py", line 76, in backend
    raise ImportError('this platform is not supported: {}'.format(
ImportError: this platform is not supported: ('failed to acquire X connection: Can\'t connect to display ":0": b\'Authorization required, but no authorization protocol specified\\n\'', DisplayConnectionError(':0', b'Authorization required, but no authorization protocol specified\n'))

Try one of the following resolutions:

 * Please make sure that you have an X server running, and that the DISPLAY environment variable is set correctly```

答案1

事实证明@ArkadiuszDrabczyk是正确的。我使用的是 Wayland,因为 Ubuntu 默认使用 Wayland。我刚刚切换到 Xorg,它开始工作正常。

要切换到 Xorg:

  1. 注销ubuntu(也可以重新启动,但不是必须的)
  2. 单击密码部分下方的齿轮
  3. 单击 Xorg 上的 Ubuntu

这会将 Xorg 设置为默认值,因此您不必不断切换到它。

来源:https://www.maketecheasier.com/switch-xorg-wayland-ubuntu1710/

相关内容