1

I using Python autopilot.input.Mouse in AutoKey for simulate mouse (move, click) in Ubuntu

and search a solution for

mouse wheel scrolling down

My AutKey-Prototype using pyautogui (installed by pip3 install pyautogui linuxhint.com) does nothing:

# pip3 install pyautogui
import pyautogui
pyautogui.scroll(20)

Any idea how to do that in Phyton or AutoKey?

System

Operating System: Kubuntu 20.04
KDE Plasma Version: 5.18.5
KDE Frameworks Version: 5.68.0
Qt Version: 5.12.8
Kernel Version: 5.4.0-52-generic
OS Type: 64-bit
SL5net
  • 2,282
  • 4
  • 28
  • 44

1 Answers1

1

Solution

Open AutoKey and click: Edit>Preferences>Script Engine> and select a folder where the pyautogui is located (or contained).

For me that was:

home/<my linux username>/anaconda3/lib/python3.7/site-packages

Approach

I initially tried:

import mouse
mouse.wheel(delta=1)

But that requires sudo, and from what I read here it appears the AutoKey does not like the mouse module too much. Running this script from AutoKey gave the error:

ImportError:You must be root to use this library on Linux`

Then I tried your module named pyautogui. That gave the error that it could not find the module pyautogui even though it was installed.

I first installed pyautogui on the Anaconda base environment with pip install pyautogui. Though it could not find it, so I deactivated anaconda with conda deactivate and installed again on the linux python version with pip install pyautogui. AutoKey could (still) not find it after restarting AutoKey. But after linking to the package of pyautogui it could find it.

Room for Improvement

I think this solution can be improved by automating it, as it is a basic functionality that one might like in every (new instance) of a Ubuntu OS. Therefore, the AutoKey could be installed automatically, along with the pyautogui. If the location is determined where autokey stores this preference, it can be set automatically.

Also, I don't have it working yet in jupyter notebook.

a.t.
  • 2,002
  • 3
  • 26
  • 66