Problem
Am looking to automatically move the mouse cursor and simulate mouse button clicks from the command-line using an external script. Am not looking to:
Ideal Solution
What I'd like to do is the following:
mouse-script.txt
).(x, y, rate) = (500, 500, 50) sleep = 5 click = left
xsim < mouse-script.txt
.Question
How do you automate mouse movement so that it transitions from its current location to another spot on the screen, at a specific velocity? For example:
xdotool mousemove 500 500 --rate 50
The --rate 50
doesn't exist with xdotool
.
# of the screen then change mousemove_relative to mousemove in the xdotool command below. # Set LENGTH to 0 if you do not want the mouse pointer to actually move. # Set LENGTH to 1 if you want the mouse pointer to move just a tiny fraction. # Set LENGTH to e.g. 100 if you want to see more easily the mouse pointer move.
In the Appearance panel that appears on the right you just need to click on the menu picker beside the 'cursor' option (it'll read 'Yaru' by default) and select from the cursor themes installed on your system. You'll quickly discover that Ubuntu doesn't ship with many pointer packs out of the box.
This feature is called mouse keys. Open the Activities overview and start typing Accessibility. You can access the Activities overview by pressing on it, by moving your mouse pointer against the top-left corner of the screen, by using Ctrl + Alt + Tab followed by Enter , or by using the Super key.
on newer versions of Ubuntu (14.04+), you can use Autopilot, a UI testing tool for Ubuntu. It is made for creating and running user interface tests, but can also be used for basic GUI automation tasks.
to install:
$ sudo apt-get install python3-autopilot
an example script (Python3) to automate mouse movement:
#!/usr/bin/env python3
from autopilot.input import Mouse
mouse = Mouse.create()
mouse.move(100, 50)
mouse.click()
You would run this just like any other Python3 script. Watch your mouse pointer move!
xaut
for PythonREADME
instructionssudo apt-get install swig x11proto-xext-dev libx11-dev libxtst-dev cd /usr/local/src tar zxf xaut-0.2.0.tar.gz ./configure
src/Makefile
CFLAGS
line as follows:CFLAGS = -Wall -fPIC -fno-stack-protector
make
/usr/local/src/xaut-0.2.0/python/build/lib/*
to a new directory.mm.py
:import xaut mouse = xaut.mouse() delay mouse.move_delay( 100 ) mouse.move( 500, 500 )
python mm.py
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With