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()