vishal vishal - 1 year ago 96
Bash Question

Control mouse by writing to /dev/input/mice

I am using Ubuntu 12.04. For one of my applications I require to control the mouse in software using a script.

I understand that the mouse device is

. If I do a
cat /dev/input/mice
and then move my mouse, I see a lot of output being dumped to the screen.

Now I wish to remove the mouse, and have a script which writes to
in order to control the mouse pointer

Please help me with commands for the following:

(1) Perform a left click

(2) Perform a right click

(3) Move the mouse from one location to another.

Kindly note that I am looking for a shell script solution, rather than a C/C++ solution.

Answer Source

this is not trough the file you mentioned, but its way quicker to use this tool instead of decypering the dump of that file. And it does everything you want in bash.

xdotool does the trick in my terminal.
this is the package site for ubuntu. you probably can install it trough

# apt-get install xdotool

I could just emerge it on gentoo without adding any repositories.
the tool works fairly simple:

#! /bin/bash
# move the mouse  x    y
xdotool mousemove 1800 500
# left click
xdotool click 1
# right click
xdotool click 3

found it here