python实现找色

coding=utf-8

import win32gui, win32api, win32con, time
from PIL import ImageGrab

def PilImage(x, y):
win32api.keybd_event(win32con.VK_SNAPSHOT, 0)
time.sleep(0.2)
im = ImageGrab.grabclipboard()
pix = im.load()
time.sleep(0.2)
return pix[x, y]

print PilImage(500, 500)
i =0
while 1:
if PilImage(500, 500) != (64, 64, 64):
print “success”
i = i+1
print i

你可能感兴趣的:(模拟按键)