def auto_click(): util.log_h1(f'前置准备') if sc.dir_check(): auto.open_driver() dm.model_load() while (True): util.log_h1_start(f'开始') start_time = time.time() if sc.task(): min_index = dm.model_predict(c.crop_4_img_paths) sc.save_data_img(min_index) target_x, target_y = sc.find_xy_indesktop( c.crop_4_img_paths[min_index]) if target_x == 0 and target_y == 0: util.log_title('匹配失败') else: auto.move_to(target_x, target_y) if sc.shot(): now_x, now_y = sc.find_mouse_in_desktop() move_x = target_x - now_x + c.mouse_move_shape[0] move_y = target_y - now_y + c.mouse_move_shape[1] auto.move_rel_click(move_x, move_y) end_time = time.time() cost_time = end_time - start_time util.log_h1_end(f'结束 耗时 %.3f' % cost_time) time.sleep(3)
def run_test(): util.log_h1_start(f'开始') start_time = time.time() realtest() end_time = time.time() cost_time = end_time - start_time util.log_h1_end(f'结束 耗时 %.3f' % cost_time) exit()
def run_test(): util.log_h1(f'前置准备') if flow.dir_check(): auto.open_driver() if (True): util.log_h1_start(f'开始') start_time = time.time() flow.test() end_time = time.time() cost_time = end_time - start_time util.log_h1_end(f'结束 耗时 %.3f' % cost_time) time.sleep(3) exit()
def move_learn(): sc.dir_check() util.log_title('图片朝向确认') confirm = input( f'请确认路径 {os.path.abspath(c.new_front_img_dir)} 下图片朝向均为 > 前 < : (确认后输入 Y , 输入其他退出) ' ) if confirm == 'Y' or confirm == 'y': confirm = input( f'请确认路径 {os.path.abspath(c.new_others_img_dir)} 下图片朝向均为 > 左 右 后 < : (确认后输入 Y , 输入其他退出)' ) if confirm == 'Y' or confirm == 'y': util.log_h1_start('开始') sc.move_new_to_train() util.log_h1_end('结束')
def taskxingbensp(): global lastTime global lastState util.log_h1_start(f'开始') start_time = time.time() battle_time = 0 while (True): time.sleep(0.5) if sc.shot() and sc.image_check(c.img_sc_path, c.screen_size): ## 截图 sc.acrop() ## 分截图 if sc.is_error(): ## 如果出现错误页面 直接刷新 auto.refresh() continue if sc.is_validate(): ## 出现验证码 最高优先级事件 退出并报警 dealValidate() continue if lastTime > 8: auto.refresh() lastTime = 0 continue if sc.is_summon(): setState('summon') selectSummon('titan') continue if sc.is_readysum(): setState('readysum') auto.toclick(419, 759) continue if sc.is_batload(): setState('batload') continue if sc.is_resload(): setState('resload') # auto.toclick(112,532) continue if sc.is_battle(): if sc.is_fa() == 2: auto.toclick(112, 532) if sc.is_fa() == 1: isattack = sc.is_attack() if isattack == 0: auto.refresh() continue if isattack == 1: setState('attack') continue continue exupx, exupy = sc.find_xy(c.exup_flag_img_path) if exupx > 0 and exupy > 0: print('ex升级 状态', exupx, exupy) auto.toclick(exupx, exupy) setState('exup') continue if sc.is_result(): setState('result') return if sc.is_halfhong_window(): okx, oky = sc.find_xy(c.halfhong2_flag_img_path) if okx > 0 and oky > 0: print('小红弹窗 状态', okx, oky) oky = oky + 100 auto.toclick(okx, oky) time.sleep(0.5 + random.random() / 10) auto.toclick(okx, oky + 400) time.sleep(0.5 + random.random() / 10) auto.toclick(okx, oky + 55) setState('halfhong') continue if sc.is_halfhongrecover_window(): okx, oky = sc.find_xy(c.ok_flag_img_path) if okx > 0 and oky > 0: print('吃完小红弹窗 状态', okx, oky) auto.toclick(okx, oky) setState('ok') continue if sc.is_trophy_window(): okx, oky = sc.find_xy(c.closebutton_flag_img_path) if okx > 0 and oky > 0: print('获得成就弹窗 状态', okx, oky) auto.toclick(okx, oky) setState('close') continue if sc.is_exp_window() or sc.is_honor_window( ) or sc.is_nightmare_window() or sc.is_neterror_window(): okx, oky = sc.find_xy(c.ok_flag_img_path) if okx > 0 and oky > 0: print('按钮 状态', okx, oky) auto.toclick(okx, oky) setState('ok') continue if sc.is_event(): toTag() # 走到这里就是未识别的场景 直接exit setState('error') print('此场景未识别') if lastState == 'error' and lastTime > 3: exit() continue return False end_time = time.time() cost_time = end_time - start_time util.log_h1_end(f'结束 耗时 %.3f' % cost_time) time.sleep(1)