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 main(): screen.shot() question_options = localocr.getText() wiki_search = Wiki(question_options['question'], question_options['options']) wiki_result = wiki_search.getResults() google_search = GoogleSearch() google_search_result = google_search.getResult( question_options['question'], question_options['options']) wiki_index = wiki_result.index(max(wiki_result)) google_index = google_search_result.index(max(google_search_result)) print("WIKI FOUND: " + str(question_options['options'][wiki_index]) + "\t Frequency of Option: " + str(wiki_result[wiki_index])) print("GOOGLE FOUND: " + str(question_options['options'][google_index]) + "\t Number of Results: " + str(google_search_result[google_index]))
def test(): print() if sc.shot(): ## 截图 if sc.image_check(c.img_sc_path, c.screen_size): ## 检查截图大小 sc.acrop() is_stepload() print(c.validate1_store_img_path) location, score = sc.template_match(c.validate_flag_img_path, c.validate1_store_img_path) sc.is_validate() print(location, score) dealValidate() exit() sc.is_attack() sc.is_error() sc.is_main() sc.is_raid() sc.is_result() sc.is_battle() sc.is_batload() sc.is_resload() sc.is_summon() sc.is_readysum() sc.is_fa() sc.is_event() if sc.is_exp_window() or sc.is_honor_window( ) or sc.is_nightmare_window(): okx, oky = sc.find_xy(c.ok_flag_img_path) if okx > 0 and oky > 0: print('弹窗 状态', okx, oky) auto.toclick(okx, oky) if sc.is_result(): if sc.is_again_result(): print('继续结算页 状态') # againx, againy = sc.is_again_result(c.again_flag_img_path) # if againx>0 and againy>0: # print('结算页继续 状态', againx, againy) # auto.toclick(againx,againy) 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) location, score = sc.template_match(c.exup_flag_img_path, c.img_sc_path) print('ex升级 打分', score) if score > 3: print('ex升级 状态', score) location, score = sc.template_match(c.ok_flag_img_path, c.img_sc_path) print('弹窗 打分', score) if score > 3: print('弹窗 状态', score) return True return False
def doshot(): shot_path = shot() if shot_path != None: itchat.send_image(shot_path, group_id)
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)