def check_yys_window(index): window = Window() window_name = "[#] [yys" + str(index) + "] 阴阳师-网易游戏 [#]" handle = window.check_window(window_name) if handle == 0: return window_name + "不存在" return window_name + "窗口句柄:[" + str(handle) + "]"
def tuo(self, src_x, src_y, tar_x, tar_y): m = Mouse(self.metrics_x, self.metrics_y) dx = tar_x - src_x dy = tar_y - src_y x = src_x y = src_y m.mouse_to(x, y) # 鼠标移动到 m.left_down() i = 1 ddy = int(dy / 10) while i < 10: time.sleep(0.03) m.mouse_to(x, y + ddy * i) # 鼠标移动到 i += 1 i = 1 ddx = int(dx / 10) while i < 10: time.sleep(0.05) m.mouse_to(x + ddx * i, tar_y) # 鼠标移动到 i += 1 time.sleep(0.1) m.mouse_to(tar_x + 3, tar_y) # 鼠标移动到 time.sleep(0.3) m.left_up() time.sleep(1) Window.temp_jie_tu(self.handle) # 更新截图 return
def get_text(self, name): re = Window.get_window(self.m_handle, None, name) if re != 0: print("找不到窗口:" + name) return "" else: print("窗口:" + name) win32gui.ShowWindow(self.m_handle.hwnd, 1) win32gui.SetForegroundWindow(self.m_handle.hwnd) time.sleep(0.3) re = Window.get_window(self.m_handle, None, name) if re != 0: print("找不到窗口:" + name) return "" else: print("窗口:" + name) center_x = (self.m_handle.right + self.m_handle.left) / 2 center_y = (self.m_handle.bottom + self.m_handle.top) / 2 mouse = Mouse() mouse.click(int(center_x), int(center_y)) time.sleep(0.3) key_board = Keyboard() key_board.ctrl_A_C() time.sleep(0.3) win32gui.ShowWindow(self.m_handle.hwnd, 2) text = SendQQ.get_clipboard_text() cmd = SendQQ.get_last_cmd(text, name) return cmd
def try_get_qq(self): self.qq_name = self.lineEdit_qqname.text() if self.qq_name != '': handle = Window.check_window(self.qq_name) if handle != 0: Fuben.get_qq_cmd(self.qq_name) return 0
def __init__(self, name): class_name = None re = Window.get_window(self.m_handle, class_name, name) if re != 0: print("找不到窗口:" + name) #self.add_log("找不到窗口:" + name + str(handle.hwnd) + "\r\n") else: print("窗口:" + name)
def dian_guai_11(self): yys1 = self.comboBox_1.currentText() yys_handle = Handle() self.add_in_text_browser("点主怪\r\n") if Window.get_window(yys_handle, None, "[#] [yys" + yys1 + "] 阴阳师-网易游戏 [#]") == codedef.NORMAL_END: x = int((yys_handle.right + yys_handle.left) / 2) xishu = 0.2 y = int((yys_handle.top + (yys_handle.bottom - yys_handle.top) * xishu)) m = Mouse() m.click(x, y)
def setqqname(self): self.qq_name = self.lineEdit_qqname.text() if self.qq_name != '': handle = Window.check_window(self.qq_name) if handle != 0: self.add_in_text_browser("qq设置成功\r\n") else: self.add_in_text_browser("qq聊天窗口不存在,qq设置失败\r\n") self.lineEdit_qqname.setText('') return 0
def testtt(): h = Window.check_window("[#] [yys1] 阴阳师-网易游戏 [#]") print(h) sleep_time = 1 if h != 0: game = Team_kun_25_captain(codedef.UP_C_COIN, False) yys1 = Handle() win32gui.ShowWindow(yys1.hwnd, 1) re = game.set_window(yys1, "[#] [yys1] 阴阳师-网易游戏 [#]", 1, True) if re != 0: return re while 1: scene = game.get_scene(yys1) captain_wait = game.do_work(scene, yys1) time.sleep(2)
def fight_UP_guai(self, handle, UP, target_img_path): src_img_path1 = 'temp/temp1.bmp' Window.temp_jie_tu(handle, src_img_path1) if self.witch_up(handle, UP, src_img_path1, target_img_path) == codedef.NORMAL_END: return codedef.NORMAL_END time.sleep(0.4) src_img_path2 = 'temp/temp2.bmp' Window.temp_jie_tu(handle, src_img_path2) if self.witch_up(handle, UP, src_img_path2, target_img_path) == codedef.NORMAL_END: return codedef.NORMAL_END time.sleep(0.4) src_img_path3 = 'temp/temp3.bmp' Window.temp_jie_tu(handle, src_img_path3) if self.witch_up(handle, UP, src_img_path3, target_img_path) == codedef.NORMAL_END: return codedef.NORMAL_END return codedef.ERROR_END
def team_kun_25(self, captain, teammate, UP, BOSS, QingMax, Beater, BeatMax, imax_times, Chapter): if Window.check_window("[#] [yys" + captain + "] 阴阳师-网易游戏 [#]") == 0 \ or Window.check_window("[#] [yys" + teammate + "] 阴阳师-网易游戏 [#]") == 0: self.add_log("沙盒窗口不完全存在,进程结束。\r\n") return codedef.NORMAL_END if captain == teammate: self.add_log("单人探索\r\n") self.team_kun_25_one(captain, UP, BOSS, QingMax, Beater, BeatMax, imax_times, Chapter) return codedef.NORMAL_END game = Team_kun_25_captain(UP=UP, BOSS=BOSS, QingMax=QingMax, Beater=Beater, BeatMax=BeatMax, Chapter=Chapter) yys1 = Handle() self.set_yys(captain, game, yys1) game2 = Team_kun_25_teammate(Beater=Beater, BeatMax=BeatMax) yys2 = Handle() self.set_yys(teammate, game2, yys2) times = 0 ju_flag = False oldc_c = '' while 1: # 队长 scene = game.get_scene(yys1) if oldc_c != str(scene): oldc_c = str(scene) self.add_log(str(scene) + "\r\n") re = game.do_work(scene, yys1) if re > 0: self.add_log('队长满级数量' + str(re) + "\r\n") if re == codedef.BEGIN_DA_GUAI or re == codedef.BEGIN_DA_BOSS: ju_flag = True elif re == codedef.FIGHT_END and ju_flag is True: ju_flag = False times = times + 1 self.add_log(times.__str__() + "\r\n") if times > imax_times: self.add_log("达到最大次数,进程结束\r\n") self.send_qq(r'困25 达到最大次数,进程结束') return codedef.NORMAL_END elif re == codedef.SCENCE_REPEAT_END: self.add_log("场景重复超限\r\n") self.send_qq_jie_tu(yys1) return codedef.NORMAL_END elif re == codedef.TANG_GO_RIGHT: yys1.iold_scene = 0 yys2.iold_scene = 0 elif re == codedef.EXIT_TANG_SUO: game2.set_exit(True) elif re == codedef.YAO_QING_ZHONG: yys1.iold_scene = 0 yys2.iold_scene = 0 # 队员 scene = game2.get_scene(yys2) if oldc_c != str(scene): oldc_c = str(scene) self.add_log(str(scene) + "\r\n") if scene == SceneKey.TANG_SUO or scene == SceneKey.TANG_SUO_ZHANG_JIE: game.set_yao_qing(True) # 队长可邀请 re = game2.do_work(scene, yys2) if re > 0: self.add_log('队友满级数量' + str(re) + "\r\n") if re == codedef.ZAI_TANG_SUO: game.set_da_guai(True)
def hun_shi(self, y1, y2, y3, imax_times): if Window.check_window("[#] [yys" + y1 + "] 阴阳师-网易游戏 [#]") == 0 \ or Window.check_window("[#] [yys" + y2 + "] 阴阳师-网易游戏 [#]") == 0 \ or Window.check_window("[#] [yys" + y3 + "] 阴阳师-网易游戏 [#]") == 0: self.add_log("沙盒窗口不完全存在,进程结束。\r\n") return codedef.NORMAL_END game = Team_hun_10() yys1 = Handle() yys2 = Handle() yys3 = Handle() self.set_yys(y1, game, yys1) self.set_yys(y2, game, yys2) self.set_yys(y3, game, yys3) ju_flag = False # dian_guai_flag = 0 # dian_guai_time = 0 times = 0 # t = time.time() # print(t) # 原始时间数据 # print(int(t)) re1 = codedef.NORMAL_END re2 = codedef.NORMAL_END re3 = codedef.NORMAL_END while 1: scene = game.get_scene(yys1) # 手动阵容需点怪 # if scene == SceneKey.ZHANG_DOU_ZHONG or scene == SceneKey.NUKOWN: # if dian_guai_flag == 1: # dian_guai_flag = 2 # dian_guai_time = int(time.time()) # elif dian_guai_flag == 2 and int(time.time()) - dian_guai_time >= 11: # dian_guai_flag = 3 # game.dian_guai_11(yys1) # self.add_log("yys" + y1 + "点主怪\r\n") # time.sleep(1) # game.dian_guai_11(yys1) # # elif dian_guai_flag == 3 and int(time.time()) - dian_guai_time >= 27: # dian_guai_flag = 4 # game.dian_guai_11(yys1) # self.add_log("yys" + y1 + "点主怪\r\n") # time.sleep(1) # game.dian_guai_11(yys1) # # elif dian_guai_flag == 4 and int(time.time()) - dian_guai_time >= 27: # 34 # dian_guai_flag = 5 # game.dian_guai_11(yys1) # self.add_log("yys" + y1 + "点主怪\r\n") # time.sleep(1) # game.dian_guai_11(yys1) # 手动阵容需点怪 re1 = game.do_work(scene, yys1) self.add_log(scene.__str__() + str(re1) + "\r\n") if re1 == codedef.SCENCE_REPEAT_END: self.add_log("yys" + y1 + "场景重复超限\r\n") self.send_qq_jie_tu(yys1) elif re1 == codedef.FIGHT_BEGIN and ju_flag is False: ju_flag = True # dian_guai_flag = 1 elif re1 == codedef.FIGHT_END and ju_flag is True: # dian_guai_time = 0 # dian_guai_flag = 0 ju_flag = False times += 1 self.add_log(times.__str__() + "\r\n") if times > imax_times: self.add_log("达到最大次数,进程结束\r\n") self.send_qq(r'御魂觉醒 达到最大次数,进程结束') return codedef.NORMAL_END elif re1 == codedef.HUN_SHI_TEAMING and re2 == codedef.HUN_SHI_TEAMING and re3 == codedef.HUN_SHI_TEAMING: self.add_log("teaming\r\n") game.teaming(scene, yys1) if scene == SceneKey.GOU_MAI_TI_LI: break time.sleep(0.6) scene = game.get_scene(yys2) re2 = game.do_work(scene, yys2) if re2 == codedef.SCENCE_REPEAT_END: self.add_log("yys" + y2 + "场景重复超限\r\n") self.send_qq_jie_tu(yys2) self.add_log(scene.__str__() + "\r\n") if scene == SceneKey.GOU_MAI_TI_LI: break time.sleep(0.6) scene = game.get_scene(yys3) re3 = game.do_work(scene, yys3) if re3 == codedef.SCENCE_REPEAT_END: self.add_log("yys" + y3 + "场景重复超限\r\n") self.send_qq_jie_tu(yys3) self.add_log(scene.__str__() + "\r\n") if scene == SceneKey.GOU_MAI_TI_LI: break time.sleep(0.6) self.send_qq(r'魂十 打完,进程结束') return codedef.NORMAL_END
def send_jie_tu(self, handle=None): window_img = Window.jie_tu(handle) image_path = "temp/qqjietu.bmp" window_img.save(image_path) self.send_qq_bmp(image_path) return 0