第一份代码是比较两幅图,找出差异来。
# -*- coding: cp936 -*-
import ctypes
import Image, ImageGrab, ImageChops
#构造RECT结构体
class RECT(ctypes.Structure):
_fields_ = [('left', ctypes.c_long),
('top', ctypes.c_long),
('right', ctypes.c_long),
('bottom', ctypes.c_long)]
def __str__(self):
return str((self.left, self.top, self.right, self.bottom))
HWND = ctypes.windll.user32.FindWindowA(None, "大家来找茬")
if HWND == 0:
print "找不到窗口"
quit()
rect =RECT()
ctypes.windll.user32.GetWindowRect(HWND,ctypes.byref(rect))
print rect
#去掉人物栏,去掉底边,去掉边框
rect0 = (rect.left+2,rect.top+190+2,rect.right-2,rect.bottom-96-2)
print rect0
width = (rect0[2] - rect0[0])/2
height = rect0[3] - rect0[1]
rect1 = (0,0,width-15,height)
rect2 = (width-1,0,rect0[2] - rect0[0