Posted by: Tito | January 16, 2010

Generate fake keyboard and mouse input in Linux

Generating keyboard and mouse input without actually pressing them can be done by command ‘xautomation’.

There are 2 commands to run xautomation: xte and xdotool.

Examples:

Move the cursor to a certain position (x,y):
xte ‘mousemove x y’
or
xdotool mousemove x y

Press a button on the keyboard:
xte  ’key a’
or
xdotool key a

Type a string:
xte ‘str abcd’
or
xdotool  type abcd

Click mouse left button:
xte ‘mouseclick 1′
or
xdotool click 1

Get current cursor position:
xdotool getmouselocation
(xte has no command).

Advertisement

Responses

  1. thank you very much needed the mouseclick thing for a flashgame to safe the life of my (computer-)mouse (:

  2. it’s very useful but I don’t more know.

  3. Mouse Input in Linux is very important commant. It’s related with mouse event.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Categories

Follow

Get every new post delivered to your Inbox.