def yuhun(): while True: #鼠标移到最右侧中止 if pyautogui.position()[0] >= pyautogui.size()[0] * 0.98: select_mode() screen = ImageGrab.grab() screen.save('screen.jpg') screen = cv2.imread('screen.jpg') #截屏,并裁剪以加速 upleft = (0, 0) downright = (2550, 770) #上部并排 a, b = upleft c, d = downright screen = screen[b:d, a:c] print('screen shot ok', time.ctime()) #设定目标,开始查找 #这里是自动接受组队 for i in ['jieshou2', "jieshou"]: want = imgs[i] size = want[0].shape h, w, ___ = size x1, x2 = upleft, (430, 358) target = action.cut(screen, x1, x2) pts = action.locate(target, want, 0) if not len(pts) == 0: print('接受组队') xx = pts[0] xx = action.cheat(xx, w, h) if xx[0] > 120: pyautogui.click(xx) t = random.randint(40, 80) / 100 time.sleep(t) break else: pass continue #自动点击通关结束后的页面 for i in ['ying', 'jiangli', 'kaishi', 'jixu']: want = imgs[i] size = want[0].shape h, w, ___ = size target = screen pts = action.locate(target, want, 0) if not len(pts) == 0: for pt in pts: pt = action.cheat(pt, w, h) pyautogui.click(pt) t = random.randint(100, 200) / 1000 time.sleep(t) break select_mode()
screen = action.screen_shot() #截屏,并裁剪以加速 upleft = (0, 0) downright = (1358, 768) downright2 = (2550, 768) print('screen shot ok', time.ctime()) #设定目标,开始查找 #进入地图后 want = imgs['guding'] #固定阵容,即在地图中 x1 = (785, 606) x2 = downright target = action.cut(screen, x1, x2) pts = action.locate(target, want, 0) if not len(pts) == 0: print('正在地图中') want = imgs['xiao'] #笑脸表情,表示在组队状态中 x1, x2 = (5, 405), (119, 560) target = action.cut(screen, x1, x2) pts = action.locate(target, want, 0) if not len(pts) == 0: print('组队状态中') else: print('退出重新组队') for i in ['queren', 'tuichu']: #否,即队友已退出,跟随退出重新组队 want = imgs[i]
def solo(): while True: #直到取消,或者出错 if pyautogui.position()[0] >= pyautogui.size()[0] * 0.98: select_mode() screen = ImageGrab.grab() screen.save('screen.png') screen = cv2.imread('screen.png') #截屏,并裁剪以加速 upleft = (0, 0) downright = (1358, 768) downright2 = (2550, 768) a, b = upleft c, d = downright screen = screen[b:d, a:c] print('screen shot ok', time.ctime()) #设定目标,开始查找 #进入后 want = imgs['guding'] x1 = (785, 606) x2 = downright target = action.cut(screen, x1, x2) pts = action.locate(target, want, 0) if not len(pts) == 0: print('正在地图中') want = imgs['left'] target = screen pts = action.locate(target, want, 0) if not len(pts) == 0: right = (854, 527) right = action.cheat(right, 10, 10) pyautogui.click(right) t = random.randint(50, 80) / 100 time.sleep(t) continue want = imgs['jian'] target = screen pts = action.locate(target, want, 0) if not len(pts) == 0: print('点击小怪') xx = action.cheat(pts[0], 10, 10) pyautogui.click(xx) time.sleep(0.5) continue else: for i in ['queren', 'tuichu']: want = imgs[i] size = want[0].shape h, w, ___ = size x1, x2 = upleft, (965, 522) target = action.cut(screen, x1, x2) pts = action.locate(target, want, 0) if not len(pts) == 0: print('退出中') try: queding = pts[1] except: queding = pts[0] queding = action.cheat(queding, w, h) pyautogui.click(queding) t = random.randint(50, 80) / 100 time.sleep(t) break continue for i in ['ying', 'jiangli', 'jixu']: want = imgs[i] size = want[0].shape h, w, ___ = size target = screen pts = action.locate(target, want, 0) if not len(pts) == 0: print('领取奖励') xy = action.cheat(pts[0], w, h - 10) pyautogui.click(xy) t = random.randint(15, 30) / 100 time.sleep(t) break want = imgs['tansuo'] size = want[0].shape h, w, ___ = size target = screen pts = action.locate(target, want, 0) if not len(pts) == 0: print('进入地图') xy = action.cheat(pts[0], w, h - 10) pyautogui.click(xy) t = random.randint(15, 30) / 100 time.sleep(t)
def goliang(): while True: #直到取消,或者出错 if pyautogui.position()[0] >= pyautogui.size()[0] * 0.98: select_mode() screen = ImageGrab.grab() screen.save('screen.jpg') screen = cv2.imread('screen.jpg') #截屏,并裁剪以加速 upleft = (0, 0) downright = (1358, 768) downright2 = (2550, 768) a, b = upleft c, d = downright screen = screen[b:d, a:c] print('screen shot ok', time.ctime()) #设定目标,开始查找 #进入后 want = imgs['guding'] x1 = (785, 606) x2 = downright target = action.cut(screen, x1, x2) pts = action.locate(target, want, 0) if not len(pts) == 0: print('正在地图中') want = imgs['xiao'] x1, x2 = (5, 405), (119, 560) target = action.cut(screen, x1, x2) pts = action.locate(target, want, 0) if not len(pts) == 0: print('组队状态中') else: print('退出重新组队') for i in ['queren', 'tuichu']: want = imgs[i] size = want[0].shape h, w, ___ = size x1, x2 = upleft, (965, 522) target = action.cut(screen, x1, x2) pts = action.locate(target, want, 0) if not len(pts) == 0: print('退出中') try: queding = pts[1] except: queding = pts[0] queding = action.cheat(queding, w, h) pyautogui.click(queding) t = random.randint(50, 80) / 100 time.sleep(t) break continue want = imgs['jieshou'] size = want[0].shape h, w, ___ = size x1, x2 = upleft, (250, 380) target = action.cut(screen, x1, x2) pts = action.locate(target, want, 0) if not len(pts) == 0: print('接受组队') xx = pts[0] xx = action.cheat(xx, w, h) if xx[0] > 120: pyautogui.click(xx) t = random.randint(40, 80) / 100 time.sleep(t) else: pass continue for i in ['ying', 'jiangli', 'jixu']: want = imgs[i] size = want[0].shape h, w, ___ = size target = screen pts = action.locate(target, want, 0) if not len(pts) == 0: print('领取奖励') xy = action.cheat(pts[0], w, h - 10) pyautogui.click(xy) t = random.randint(15, 30) / 100 time.sleep(t) break
def gouliang3(): cishu=0 while True: #直到取消,或者出错 if pyautogui.position()[0] >= pyautogui.size()[0] * 0.98: select_mode() #截屏,并裁剪以加速 upleft = (0, 0) downright = (1358, 900) downright2 = (1280, 720) a,b = upleft c,d = downright #截屏 monitor = {"top": b, "left": a, "width": c, "height": d} im = np.array(mss.mss().grab(monitor)) screen = cv2.cvtColor(im, cv2.COLOR_BGRA2BGR) #debug #cv2.imshow('image',im) #return ############################ #体力不足 want = imgs['notili'] size = want[0].shape h, w , ___ = size target = screen pts = action.locate(target,want,0) if not len(pts) == 0: print('体力不足 ') select_mode() want = imgs['queren'] size = want[0].shape h, w , ___ = size target = screen #x1,x2 = upleft, (965, 522) #target = action.cut(screen, x1, x2) pts = action.locate(target,want,0) if not len(pts) == 0: print('确认退出') try: queding = pts[1] except: queding = pts[0] xy = action.cheat(queding, w, h) pyautogui.click(xy) pyautogui.moveTo(xy) t = random.randint(15,30) / 100 time.sleep(t) #设定目标,开始查找 #进入后 want=imgs['guding'] x1 = (785, 606) x2 = downright target = action.cut(screen, x1, x2) pts = action.locate(target,want,0) if not len(pts) == 0: print('正在地图中') want = imgs['left'] target = screen pts = action.locate(target,want,0) if not len(pts) == 0: right = (854, 527) right = action.cheat(right, 10, 10) pyautogui.click(right) t = random.randint(50,80) / 100 time.sleep(t) continue for i in ['boss', 'jian']: want = imgs[i] size = want[0].shape h, w , ___ = size target = screen pts = action.locate(target,want,0) if not len(pts) == 0: print('点击小怪',i) xx = action.cheat(pts[0], w, h) pyautogui.click(xx) time.sleep(0.5) break if i=='jian' and len(pts)==0: for i in ['queren','queren2','tuichu']: want = imgs[i] size = want[0].shape h, w , ___ = size x1,x2 = upleft, (965, 522) target = action.cut(screen, x1, x2) pts = action.locate(target,want,0) if not len(pts) == 0: print('退出中',i) try: queding = pts[1] except: queding = pts[0] queding = action.cheat(queding, w, h) pyautogui.click(queding) t = random.randint(50,80) / 100 time.sleep(t) break continue for i in ['jujue','querenyuhun',\ 'tansuo','ying','jiangli','jixu','c28','ditu']: want = imgs[i] size = want[0].shape h, w , ___ = size target = screen pts = action.locate(target,want,0) if not len(pts) == 0: if i=='tansuo': cishu=cishu+1 print('探索次数:',cishu) print('领取奖励',i) xy = action.cheat(pts[0], w, h ) pyautogui.click(xy) t = random.randint(15,30) / 100 time.sleep(t) break
def gouliang2(): while True: #直到取消,或者出错 if pyautogui.position()[0] >= pyautogui.size()[0] * 0.98: select_mode() #截屏,并裁剪以加速 upleft = (0, 0) downright = (1358, 900) downright2 = (2550, 900) a,b = upleft c,d = downright #截屏 monitor = {"top": b, "left": a, "width": c, "height": d} im = np.array(mss.mss().grab(monitor)) screen = cv2.cvtColor(im, cv2.COLOR_BGRA2BGR) #设定目标,开始查找 #进入后 want = imgs['guding'] x1 = (785, 606) x2 = downright target = action.cut(screen, x1, x2) pts = action.locate(target,want,0) if not len(pts) == 0: print('正在地图中') want = imgs['xiao'] x1,x2 = (5, 405), (119, 560) target = action.cut(screen, x1, x2) pts = action.locate(target,want,0) if not len(pts) == 0: print('组队状态中') else: print('退出重新组队') for i in ['queren', 'queren2','tuichu']: want = imgs[i] size = want[0].shape h, w , ___ = size x1,x2 = upleft, (965, 522) target = action.cut(screen, x1, x2) pts = action.locate(target,want,0) if not len(pts) == 0: print('退出中',i) try: queding = pts[1] except: queding = pts[0] queding = action.cheat(queding, w, h) pyautogui.click(queding) t = random.randint(50,80) / 100 time.sleep(t) break continue for i in ['jujue','jieshou','jieshou1','ying',\ 'jiangli','jixu']: want = imgs[i] size = want[0].shape h, w , ___ = size target = screen pts = action.locate(target,want,0) if not len(pts) == 0: print('领取奖励',i) xy = action.cheat(pts[0], w, h-10 ) pyautogui.click(xy) if i=='jieshou' or i=='jieshou1': t = random.randint(15,30) / 100 else: t = random.randint(15,30) / 100 time.sleep(t) break