def find_question(): red_img = ImageGrab.grab((22, 43, 37, 56)) red_img.save("red_img.gif") size = red_img.size red_count = 0 for x in range(size[0]): for y in range(size[1]): pix = red_img.getpixel((x, y)) if pix[0] >= 240 and pix[1] <= 10 and pix[1] <= 10: red_count += 1 if red_count > 40: #if True: im = ImageGrab.grab((57, 172, 324, 188)) im.save("question.gif") result = split.split(im) index = 0 length = 80 for item in result: print index im = Image.open(item) im_len = im.size[0] + 25 length += im_len if imghash.match(item, 'dic') == True: length -= im_len / 2 break index += 1 print "\n" print "length:%d"%length m.click(length, 180)