`mouse.move()` does not work over SSH using the interactive shell
- Log into the remote computer via SSH
- Open the Python interpreter:
sudo python3 - Run the following:
import mouse
mouse.move(500, 500)
Immediately after, the text Segmentation fault prints to the screen and the interpreter exits. The SSH connection is still alive, and I can send commands to the remote computer just fine after the incident.
This problem occurs for me by connecting to both localhost from the own host and an Ngrok tunnel from a Windows 10 machine (both connecting to an Ubuntu laptop).
The host OS is Ubuntu 20.04.1 LTS, and the Python (/usr/bin/python3) version is 3.8.5.
The problem is here, XOpenDisplay(0) returns probably 0 in your situation; therefore XDefaultRootWindow goes into a SIGV (SegmentationFault) the first time it tries to dereference the pointer. It should probably raise an error on initialization, but I would also like to point out that the behaviour is not wrong in this situation, because the library can't determine what you want to do.
The problem is in _nixmouse.py
display = c_void_p(x11.XOpenDisplay(0))
window = x11.XDefaultRootWindow(display)
@Hook25 Theoretically speaking, would it be possible to move the pointer if there is a GUI somewhere enabled for the logged in user (if the remote machine is currently displaying the graphical desktop for the same user being accessed over SSH)?
Theoretically yes, but I don't think that you can do it with this library in any way that is not running a program in the remote TTY that has the X server (and client) running. If you are asking in general, without relying on this library, then definitely yes.