这是我的代码,我希望它按照我定义的值“grind()”执行。我定义了我想要使用的值,但是我不知道如何告诉它去做。基本上我希望我的程序能够:
鼠标键((625,15)),时间。睡觉(0.1),leftclick(),鼠标悬停((630,85)),时间。睡觉(0.5),左键单击(),时间。睡觉(1)当我运行它时。在import ImageGrab
import os
import time
import win32api, win32con
import ImageOps
from numpy import *
# Globals
# ------------------
x_pad = 1
y_pad = 65
def screenGrab():
b1 = (x_pad+1, y_pad+1, x_pad+1238, y_pad+704)
im = ImageGrab.grab()
##im.save(os.getcwd() + '\\Snap__' + str(int(time.time())) +'.png', 'PNG')
return im
def leftClick():
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,0,0)
time.sleep(.1)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,0,0)
print "Click."
def leftDown():
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,0,0)
time.sleep(.5)
print 'left Down'
def leftUp():
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,0,0)
time.sleep(.5)
print 'left release'
def mousePos(cord):
win32api.SetCursorPos((x_pad + cord[0], y_pad + cord[1]))
def get_cords():
x,y = win32api.GetCursorPos()
x = x - x_pad
y = y - y_pad
print x,y
class Cord:
f_spiritpt = (133, 292)
f_hp = (133, 210)
def grind():
s = screenGrab()
if ((s.getpixel(cord.f_spiritpt) == (165, 0, 0)) == (s.getpixel(cord.f_hp) == (0, 148, 21))):
mousePos((625, 15))
time.sleep(0.1)
leftclick()
mousePos((630, 85))
time.sleep(0.5)
leftClick()
time.sleep(.1)
else:
mousePos((255, 15))
time.sleep(60)
leftclick()
def main():
pass
if __name__ == '__main__':
main()