简体   繁体   中英

Follow the keyboard selection in Ubuntu preferably by Python

I am doing automation of my application. To do this at one point I need to move my mouse to selected item. I shall select the item with my keyboard and mouse will move accordingly to that point. Is there any code for doing this in Ubuntu 12.04 and 12.10. I am using Python for automation.

Assuming you:

  • Know the coordinates of the "item" you've selected in your application
  • Are using Ubuntu

You can do this inside your python script:

from subprocess import call
call(["xdotool", "mousemove", "300", "500"])

You might have to install xdotool if you don't have it installed:

sudo apt-get install xdotool

You may want to man xdotool to get more information on it - it's pretty awesome for automating keyboard/mouse events!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM