11

I've been having a problem with pyautogui. Anytime I use the functions, it works, but it uses an "invisible" mouse pointer. Basically the module doesn't use the mouse to click things, but they still click and drag. Here's a visual example:

Reading two mouse positions on the screen works as expected: Position 1 Position 2

However, when I try to move the mouse from the second link back to the first link, the mouse itself doesn't move, yet the computer thinks it does. As you can see here, the visual mouse is at link 2, while the "Invisible" mouse is at link 1. You can see this because link 1 is underlined, and also in the terminal pyautogui.position() returns the coordinates for link 1: enter image description here And using pyautogui.click() opens the first link: enter image description here

I've tried searching for answers to this problem and I can't seem to find any. It appears most people have the opposite problem. They want to be able to automate their mouse while also use it normally (ie two mouse pointers).

Why is this a problem? It's certainly not what these other people want. Often times, what happens is after a few seconds the "invisible" mouse jumps back to where the visual mouse is. Also when running click functions, if you happen to move your mouse, the "invisible" mouse will return to the visual mouse's position. Additionally, because the visual mouse doesn't move, the computer falls asleep which destroys any hope of automation. Plus because of this bug, any relative mouse movement is impossible, because it only moves relatively from the visual mouse (which is stationary).

The pyautogui script I am trying to run is a bot for a game. Previously it was working perfectly, then I wiped Xubuntu off my computer and installed Ubuntu. So this is a bug on a fresh install of Ubuntu with only a few minor changes.

My changes to my Ubuntu Install:

  • I installed GNOME desktop environment to use instead of the default (Unity I think?). Both are installed currently, but I only have GNOME selected from the login screen
  • I installed gnome-tweaks tool and changed my touchpad to area mode, as well as changed the visuals of my windows and mouse pointer to make a dark theme.
  • For the python script, I'm running python3 and am using pip version 18.1. I installed virtualenvwrapper and have the following packages installed on it:

.

$ pip freeze
numpy==1.15.4
opencv-python==3.4.3.18
Pillow==5.3.0
PyAutoGUI==0.9.38
PyMsgBox==1.0.6
PyScreeze==0.1.18
PyTweening==1.0.3
six==1.11.0
xlib==0.21

Everything else is default Ubuntu 18.04.1 LTS. Does anyone have any thoughts on how I can fix this? I would appreciate any ideas.

ExecutionByFork
  • 206
  • 1
  • 5
  • 19

1 Answers1

3

I had a similar problem. For me it was Wayland. After switching to X, it worked. Since you used Ubuntu 18.04 (which has Wayland enabled by default), I assume it's the same problem.