Created
September 25, 2012 04:07
-
-
Save fanzeyi/3779926 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import os | |
import time | |
from sh import xte | |
CACHE_FILE = "/tmp/zeray.cache" | |
SINGLE_OFFSET = 16 | |
class Xte(object): | |
def move(self, x, y): | |
assert isinstance(x, int), "Abscissa must be an integer." | |
assert isinstance(y, int), "Ordinate must be an integer." | |
xte(" ".join(["mousemove", str(x), str(y)])) | |
def leftclick(self): | |
xte("mouseclick 1") | |
def rightclick(self): | |
xte("mouseclick 3") | |
def press(self, key): | |
assert isinstance(key, str), "Press key must be a string." | |
xte(" ".join("key", key)) | |
def main(): | |
if os.path.isfile(CACHE_FILE): | |
with open(CACHE_FILE, "r") as fp: | |
count = int(fp.read()) | |
else: | |
count = 0 | |
xt = Xte() | |
xt.move(400, 100) | |
time.sleep(0.2) | |
xt.rightclick() | |
time.sleep(0.2) | |
xt.move(500, 144) | |
time.sleep(0.2) | |
xt.move(600, 144) | |
time.sleep(0.2) | |
xt.move(600, 144 + SINGLE_OFFSET * count) | |
time.sleep(0.2) | |
xt.move(700, 144 + SINGLE_OFFSET * count) | |
time.sleep(0.2) | |
xt.leftclick() | |
with open(CACHE_FILE, "w") as fp: | |
fp.write(str(count + 1)) | |
if __name__ == '__main__': | |
exit(main()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment