Skip to content
Advertisement

Emulate a mouse click without using the actual mouse on 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?

Advertisement

Answer

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
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement