Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emulate a mouse click without using the actual mouse on linux

Tags:

python

linux

I am working with a program that collects a lot of data then shows it to you in the program. Unfortunately, the program is poorly designed and requires you to "approve" each bit of data collected manually by clicking a checkbox to approve it. In order to automate this process, I wrote a small script that scans for a checkbox, clicks it, then clicks "next item".

Unfortunately, this requires moving the actual mouse, meaning I can't use my computer until the program has finished. There are other questions that reference automating this with the winapi, however none of these work on Linux. What is a way to automate this on Linux?

like image 932
Jon Avatar asked Sep 14 '25 16:09

Jon


1 Answers

You can simply start the program in a separate X server, for example using xvfb with

xvfb-run YOUR_PROGRAM

If you want to wrap just the instrumented program, that's possible too:

export DISPLAY=:42
Xvfb :42
THE_INSTRUMENTED_PROGRAMM
xdotool mousemove 1 1 click 1 # your instrumentation goes here
like image 62
phihag Avatar answered Sep 16 '25 06:09

phihag