From 1eb75708a929b77217328c387d741234c2d8a66f Mon Sep 17 00:00:00 2001 From: Cory Walker Date: Thu, 30 Jun 2011 16:34:49 -0400 Subject: [PATCH] Basic point and clicking. --- .gitignore | 1 + example.py | 8 ++++++++ py_xdotool.py | 16 ++++++++++++++++ 3 files changed, 25 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0d20b64 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.pyc diff --git a/example.py b/example.py index e69de29..e12640d 100644 --- a/example.py +++ b/example.py @@ -0,0 +1,8 @@ +from py_xdotool import * +from time import sleep + +mousemove(0, 0) +sleep(1) +click_at(100, 100, 3) +sleep(1) +click_at(500, 100, 1) diff --git a/py_xdotool.py b/py_xdotool.py index e69de29..8cc177f 100644 --- a/py_xdotool.py +++ b/py_xdotool.py @@ -0,0 +1,16 @@ +from subprocess import Popen, PIPE + +def mousemove(x, y): + c = "mousemove %d %d" % (x, y) + return run_command(c) + +def click(btn): + c = "click %d" % btn + return run_command(c) + +def click_at(x, y, btn): + mousemove(x, y) + return click(btn) + +def run_command(c): + return Popen("xdotool " + c, stdout=PIPE, shell=True).stdout.read()