From 970caafe2947df1d1873b4026fae1fafe0fc062c Mon Sep 17 00:00:00 2001 From: Jinwei Zhao Date: Mon, 14 Nov 2016 23:21:22 +0800 Subject: base python code --- bot.py | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/bot.py b/bot.py index 5effc4b..e8f7a3c 100644 --- a/bot.py +++ b/bot.py @@ -1,33 +1,32 @@ -# from pyautogui import * -import pyautogui +import pyautogui as pg from time import sleep def move(_pos, _now): if _pos == 'left' and _now == 'left': - pyautogui.typewrite(['left']) - pyautogui.typewrite(['left']) + pg.typewrite(['left']) + pg.typewrite(['left']) elif _pos == 'left' and _now == 'right': - pyautogui.typewrite(['right']) - pyautogui.typewrite(['right']) + pg.typewrite(['right']) + pg.typewrite(['right']) elif _pos == 'right' and _now == 'right': - pyautogui.typewrite(['right']) - pyautogui.typewrite(['right']) + pg.typewrite(['right']) + pg.typewrite(['right']) elif _pos == 'right' and _now == 'left': - pyautogui.typewrite(['left']) - pyautogui.typewrite(['left']) + pg.typewrite(['left']) + pg.typewrite(['left']) -width, height = pyautogui.size() +width, height = pg.size() width *= 0.5 -pyautogui.moveTo(333, 600) -pyautogui.click() +pg.moveTo(333, 600) +pg.click() posY = [360, 260, 160] posX = [276, 398] q = ['left', 'left', 'left'] -im = pyautogui.screenshot(region=(0, 0, width, height)) +im = pg.screenshot(region=(0, 0, width, height)) l0 = im.getpixel((posX[0], posY[0])) l1 = im.getpixel((posX[0], posY[1])) l2 = im.getpixel((posX[0], posY[2])) @@ -58,7 +57,7 @@ while True: move(pos, now) qlen = 0 elif qlen == 0: - im = pyautogui.screenshot(region=(0, 0, width, height)) + im = pg.screenshot(region=(0, 0, width, height)) l0 = im.getpixel((posX[0], posY[0])) l1 = im.getpixel((posX[0], posY[1])) l2 = im.getpixel((posX[0], posY[2])) -- cgit v1.2.3