def main(): """ 主函数 """ op = yes_or_no('请确保手机打开了 ADB 并连接了电脑,' '然后打开跳一跳并【开始游戏】后再用本程序,确定开始?') if not op: print('bye') return print('程序版本号:{}'.format(VERSION)) debug.dump_device_info() screenshot.check_screenshot() i, next_rest, next_rest_time = (0, random.randrange(3, 10), random.randrange(5, 10)) while True: screenshot.pull_screenshot() im = Image.open('./autojump.png') # 获取棋子和 board 的位置 piece_x, piece_y, board_x, board_y = find_piece_and_board(im) ts = int(time.time()) print(ts, piece_x, piece_y, board_x, board_y) set_button_position(im) jump(math.sqrt((board_x - piece_x)**2 + (board_y - piece_y)**2)) if DEBUG_SWITCH: debug.save_debug_screenshot(ts, im, piece_x, piece_y, board_x, board_y) debug.backup_screenshot(ts) im.close() i += 1 time.sleep(random.uniform(0.9, 1.2))
def main(): """ 主函数 """ screenshot.check_screenshot() while True: screenshot.pull_screenshot() im = Image.open('./autojump.png') # 获取棋子和 board 的位置 piece_x, piece_y, board_x, board_y = find_piece_and_board(im) ts = int(time.time()) print(ts, piece_x, piece_y, board_x, board_y) set_button_position(im) jump(math.sqrt((board_x - piece_x)**2 + (board_y - piece_y)**2)) im.close() # i += 1 # if i == next_rest: # print('已经连续打了 {} 下,休息 {}s'.format(i, next_rest_time)) # for j in range(next_rest_time): # sys.stdout.write('\r程序将在 {}s 后继续'.format(next_rest_time - j)) # sys.stdout.flush() # time.sleep(1) # print('\n继续') # i, next_rest, next_rest_time = (0, random.randrange(30, 100), # random.randrange(10, 60)) # # 为了保证截图的时候应落稳了,多延迟一会儿,随机值防 ban time.sleep(random.uniform(0.9, 1.0))
def main(): """ main :return: """ print('程序版本号:{}'.format(VERSION)) print('激活窗口并按 CONTROL + C 组合键退出') debug.dump_device_info() screenshot.check_screenshot() i, next_rest, next_rest_time = (0, random.randrange(3, 10), random.randrange(5, 10)) while True: next_page() time.sleep(1) screenshot.pull_screenshot() resize_image('autojump.png', 'optimized.png', 1024 * 1024) with open('optimized.png', 'rb') as bin_data: image_data = bin_data.read() ai_obj = apiutil.AiPlat(AppID, AppKey) rsp = ai_obj.face_detectface(image_data, 0) if rsp['ret'] == 0: beauty = 0 for face in rsp['data']['face_list']: print(face) face_area = (face['x'], face['y'], face['x'] + face['width'], face['y'] + face['height']) print(face_area) img = Image.open("optimized.png") cropped_img = img.crop(face_area).convert('RGB') cropped_img.save(FACE_PATH + face['face_id'] + '.png') # 性别判断 if face['beauty'] > beauty and face['gender'] < 50: beauty = face['beauty'] # 是个美人儿~关注点赞走一波 if beauty > BEAUTY_THRESHOLD: print('发现漂亮妹子!!!') thumbs_up() follow_user() i += 1 if i == next_rest: print('') for j in range(next_rest_time): sys.stdout.write('\r程序将在 {}秒 后继续'.format(next_rest_time - j)) sys.stdout.flush() time.sleep(1) print('\n继续') i, next_rest, next_rest_time = (0, random.randrange(30, 100), random.randrange(10, 60)) else: print(rsp) continue
def init(): print('Bot Version:{}'.format(VERSION)) debug.dump_device_info() screenshot.check_screenshot(img_path) global im, im_pixels im = Image.open(img_path) im_pixels = im.load()
def main(): """ 主函数 """ print('程序版本号:{}'.format(VERSION)) debug.dump_device_info() screenshot.check_screenshot() while True: screenshot.pull_screenshot() im = Image.open('./autojump.png') w, h = im.size im_pixel = im.load() scan_start_x = int(w / 8) # 扫描棋子时的左右边界 scan_start_y = find_scan_start_y(w, h, im_pixel) # 扫描的起始 y 坐标 # 获取棋子和 board 的位置 piece_x, piece_y = find_piece( w, h, im_pixel, scan_start_x, scan_start_y) board_x, board_y = find_board( w, h, im_pixel, piece_x, piece_y, scan_start_y) ts = int(time.time()) print(ts, piece_x, piece_y, board_x, board_y) set_button_position(w, h) jump(abs(piece_x - board_x)) if DEBUG_SWITCH: debug.save_debug_screenshot(ts, im, piece_x, piece_y, board_x, board_y) debug.backup_screenshot(ts) im.close() # 为了保证截图的时候应落稳了,多延迟一会儿,随机值防 ban time.sleep(random.uniform(1.2, 1.6))
def __init__(self): super().__init__() screenshot.check_screenshot() self.config = config.open_accordant_config('doyin') self.delay = float(self.config['delay']['value']) self.retry = int(self.config['retry']['value']) pass
def main(): """ 主函数 """ op = yes_or_no('请确保手机打开了 ADB 并连接了电脑,' '然后打开跳一跳并【开始游戏】后再用本程序,确定开始?') if not op: print('bye') return print('程序版本号:{}'.format(VERSION)) debug.dump_device_info() screenshot.check_screenshot() i, next_rest, next_rest_time = (0, random.randrange(3, 10), random.randrange(5, 10)) count = file_num('../img') jump_num = 0 while True: jump_num = jump_num + 1 print('------------>跳了'+str(jump_num)+'次<------------') time.sleep(0.5) screenshot.pull_screenshot() imgPath='./autojump.png' im = Image.open(imgPath) img_rgb = cv2.imread(imgPath) count = count+1 # cv2.imwrite('../img/'+'{}.png'.format(count), img_rgb) # print('-----****------>writing img to ../img/''{}.png'.format(count)) # 获取棋子和 board 的位置 piece_x, piece_y, board_x, board_y = combine_opencv.find_jumper_and_board(imgPath,show=False) ts = int(time.time()) print(ts, piece_x, piece_y, board_x, board_y) set_button_position(im) jump(math.sqrt((board_x - piece_x) ** 2 + (board_y - piece_y) ** 2)) if DEBUG_SWITCH: debug.save_debug_screenshot(ts, im, piece_x, piece_y, board_x, board_y) debug.backup_screenshot(ts) im.close() i += 1 if i == 1000: print('已经连续打了 {} 下,休息 {}s'.format(i, next_rest_time)) for j in range(next_rest_time): sys.stdout.write('\r程序将在 {}s 后继续'.format(next_rest_time - j)) sys.stdout.flush() time.sleep(1) print('\n继续') i, next_rest, next_rest_time = (0, random.randrange(30, 100), random.randrange(10, 60)) # 为了保证截图的时候应落稳了,多延迟一会儿,随机值防 ban time.sleep(random.uniform(0.9, 1.2))
def main(): """ main :return: """ print('程序版本号:{}'.format(VERSION)) print('激活窗口并按 CONTROL + C 组合键退出') #调试 debug.dump_device_info() #截图分析 screenshot.check_screenshot() while True: next_page() time.sleep(1) screenshot.pull_screenshot() resize_image('autojump.png', 'optimized.png', 1024 * 1024) # n=random.randint(1,3) # print('n:',n) # # if n ==3 or n==1: # # 关注点赞走一波 # time.sleep(1) action.action.move('center_point') #ocr.main() print('点赞并关注!!!')
def main(): """ main :return: """ global img global imgOrg print('程序版本号:{}'.format(VERSION)) print('激活窗口并按 CONTROL + C 组合键退出') debug.dump_device_info() screenshot.check_screenshot() while True: next_page() time.sleep(1) im = screenshot.pull_screenshot() cropped = im.crop((0, 0, 916, 1920)) # (left, upper, right, lower) cropped.load() cropped.save("./cropped.png") cropped.close() im.close() # resize_image('cropped.png', 'optimized.png', 1024*1024) with open('cropped.png', 'rb') as bin_data: image_data = bin_data.read() ai_obj = apiutil.AiPlat(SecretId, SecretKey) rsp = ai_obj.face_detectface(image_data) major_total = 0 minor_total = 0
def main(): """ main :return: """ print('程序版本号:{}'.format(VERSION)) print('激活窗口并按 CONTROL + C 组合键退出') debug.dump_device_info() screenshot.check_screenshot() while True: next_page() time.sleep(1) screenshot.pull_screenshot() resize_image('autojump.png', 'optimized.png', 1024 * 1024) with open('optimized.png', 'rb') as bin_data: image_data = bin_data.read() ai_obj = apiutil.AiPlat(AppID, AppKey) rsp = ai_obj.face_detectface(image_data, 0) major_total = 0 minor_total = 0 if rsp['ret'] == 0: beauty = 0 for face in rsp['data']['face_list']: print(face) face_area = (face['x'], face['y'], face['x'] + face['width'], face['y'] + face['height']) if face['width'] * face['height'] < 5000: continue print(face_area) img = Image.open("optimized.png") cropped_img = img.crop(face_area).convert('RGB') cropped_img.save(FACE_PATH + face['face_id'] + '.png') # 性别判断 if face['beauty'] > beauty and face['gender'] < 50: beauty = face['beauty'] if face['age'] > GIRL_MIN_AGE: major_total += 1 else: minor_total += 1 # 是个美人儿~关注点赞走一波 if beauty > BEAUTY_THRESHOLD and major_total > minor_total: print('发现漂亮妹子!!!') #thumbs_up() #follow_user() getUserProfile() back() else: print(rsp) continue
def main(): """ 主函数 """ op = yes_or_no('请确保手机打开了 ADB 并连接了电脑,' '然后打开跳一跳并【开始游戏】后再用本程序,确定开始?') if not op: print('bye') return print('程序版本号:{}'.format(VERSION)) debug.dump_device_info() screenshot.check_screenshot() ####################################### # # # 物理外挂部分 # # # ####################################### ser = serial.Serial() ser.baudrate = 9600 #波特率 ser.port = 'COM3' # Arduino连接的COM口,根据实际情况修改 ser.open() #打开串口之前记得关闭Arduino IDE的串口工具和其他串口工具 if ser.is_open: print("和Arduino握手成功!") i, next_rest, next_rest_time = (0, random.randrange(3, 10), random.randrange(5, 10)) while True: screenshot.pull_screenshot() im = Image.open('./autojump.png') # 获取棋子和 board 的位置 piece_x, piece_y, board_x, board_y = find_piece_and_board(im) ts = int(time.time()) print(ts, piece_x, piece_y, board_x, board_y) set_button_position(im) jump(math.sqrt((board_x - piece_x) ** 2 + (board_y - piece_y) ** 2)) if DEBUG_SWITCH: debug.save_debug_screenshot(ts, im, piece_x, piece_y, board_x, board_y) debug.backup_screenshot(ts) im.close() ser.write(milsec) time.sleep(3) # i += 1 # if i == next_rest: # print('已经连续打了 {} 下,休息 {}s'.format(i, next_rest_time)) # for j in range(next_rest_time): # sys.stdout.write('\r程序将在 {}s 后继续'.format(next_rest_time - j)) # sys.stdout.flush() # time.sleep(1) # print('\n继续') # i, next_rest, next_rest_time = (0, random.randrange(30, 100), # random.randrange(10, 60)) # 为了保证截图的时候应落稳了,多延迟一会儿,随机值防 ban time.sleep(random.uniform(0.9, 1.2))
def main(): op = yes_or_no("请确保手机通过adb连上了电脑," "进入微信跳一跳,点击【开始游戏】,确定开始?") if not op: print('bye') return # #显示设备信息(要补充) debug.find_service_inf() # #检查设备截图方式 screenshot.check_screenshot()
def main(): """ 主函数 """ op = yes_or_no('请确保手机打开了 ADB 并连接了电脑,' '然后打开跳一跳并【开始游戏】后再用本程序,确定开始?') if not op: print('bye') return # 设置最大分数 score = input("请输入想达到的最大分数:") try: init_set_score(int(score)) except: pass print('程序版本号:{}'.format(VERSION)) debug.dump_device_info() screenshot.check_screenshot() i, next_rest, next_rest_time = (0, random.randrange(3, 10), random.randrange(5, 10)) while True: screenshot.pull_screenshot() im = Image.open('./autojump.png') # 判断是否想退出 print("====") if want_to_die(im): break print("====") # 获取棋子和 board 的位置 piece_x, piece_y, board_x, board_y = find_piece_and_board(im) ts = int(time.time()) print(ts, piece_x, piece_y, board_x, board_y) set_button_position(im) jump(math.sqrt((board_x - piece_x) ** 2 + (board_y - piece_y) ** 2)) if DEBUG_SWITCH: debug.save_debug_screenshot(ts, im, piece_x, piece_y, board_x, board_y) debug.backup_screenshot(ts) im.close() i += 1 if i == next_rest: print('已经连续打了 {} 下,休息 {}s'.format(i, next_rest_time)) for j in range(next_rest_time): sys.stdout.write('\r程序将在 {}s 后继续'.format(next_rest_time - j)) sys.stdout.flush() time.sleep(1) print('\n继续') i, next_rest, next_rest_time = (0, random.randrange(30, 100), random.randrange(10, 60)) # 为了保证截图的时候应落稳了,多延迟一会儿,随机值防 ban time.sleep(random.uniform(1.7, 2.2))
def main(): """ main :return: """ print('程序版本号:{}'.format(VERSION)) print('激活窗口并按 CONTROL + C 组合键退出') debug.dump_device_info() screenshot.check_screenshot() while True: next_page() time.sleep(1) screenshot.pull_screenshot() resize_image('autojump.png', 'optimized.png', 1024*1024) with open('optimized.png', 'rb') as bin_data: image_data = bin_data.read() ai_obj = apiutil.AiPlat(AppID, AppKey) rsp = ai_obj.face_detectface(image_data, 0) major_total = 0 minor_total = 0 if rsp['ret'] == 0: beauty = 0 for face in rsp['data']['face_list']: print(face) face_area = (face['x'], face['y'], face['x']+face['width'], face['y']+face['height']) print(face_area) img = Image.open("optimized.png") cropped_img = img.crop(face_area).convert('RGB') cropped_img.save(FACE_PATH + face['face_id'] + '.png') # 性别判断 if face['beauty'] > beauty and face['gender'] < 50: beauty = face['beauty'] if face['age'] > GIRL_MIN_AGE: major_total += 1 else: minor_total += 1 # 是个美人儿~关注点赞走一波 if beauty > BEAUTY_THRESHOLD and major_total > minor_total: print('发现漂亮妹子!!!') thumbs_up() follow_user() else: print(rsp) continue
def __init__(self): self.config = config.open_accordant_config('wechat') self.delay = float(self.config['delay']['value']) self.retry = int(self.config['retry']['value']) screenshot.check_screenshot() # 朋友圈截图区域 self.sns_region = self.get_sns_region() # 缓存好友信息 self.temp = {} # 统计翻页 self.page = 1
def main(): """ main :return: """ print('程序版本号:{}'.format(VERSION)) print('激活窗口并按 CONTROL + C 组合键退出') debug.dump_device_info() screenshot.check_screenshot() #TencentRun() FacePPRun()
def main(): screenshot.check_screenshot() while True: print("INFO:正在截取手机屏幕") im = screenshot.pull_screenshot() if debug_mode: print("Debug:image_size:", im.size) print("INFO:正在检查状态") status = check_status(im) print("INFO:当前状态:", status) action(status) time.sleep(random.uniform(1, 2)) im.close()
def test_getClickPos(self): screenshot.check_screenshot() im = screenshot.pull_screenshot2CV() cv2.namedWindow("match", cv2.WINDOW_NORMAL) cv2.setMouseCallback("match", onmouse, 0) cv2.imshow("match", im) cv2.waitKey() cv2.destroyAllWindows() pos = -int(pos[0]), 443 - int(pos[1]) adb.tap_scale(pos, scale, adb) adb.swipe_scale(pos, scale, adb)
def get_screenshot(): screenshot.check_screenshot() screenshot.pull_screenshot() im = Image.open(r"./screenshot.png") #导入手机截图 img_size = im.size w = im.size[0] # h = im.size[1] print("xx:{}".format(img_size)) region = im.crop((70,300, w-70,600)) #裁剪的区域,可以自己修改 enh_con = ImageEnhance.Contrast(region) image_contrasted = enh_con.enhance(1.5) image_contrasted.save("./crop_test1.png") #提取题目截图
def main(): """ 主函数 """ op = yes_or_no( 'Please make sure that the phone has opened ADB and connected to Yanshee,' 'Then open and "jump game" and start the game, then run this program? ' ) if not op: print('bye') return print("Exit program: press CTRL + C\n") print('Program version:{}'.format(VERSION)) debug.dump_device_info() screenshot.check_screenshot() i, next_rest, next_rest_time = (0, random.randrange(3, 10), random.randrange(5, 10)) action_func(startAction, 1) while True: screenshot.pull_screenshot() im = Image.open('./autojump.png') # 获取棋子和 board 的位置 piece_x, piece_y, board_x, board_y = find_piece_and_board(im) ts = int(time.time()) print(ts, piece_x, piece_y, board_x, board_y) set_button_position(im) jump(math.sqrt((board_x - piece_x)**2 + (board_y - piece_y)**2)) if DEBUG_SWITCH: debug.save_debug_screenshot(ts, im, piece_x, piece_y, board_x, board_y) debug.backup_screenshot(ts) im.close() # i += 1 # if i == next_rest: # print('已经连续打了 {} 下,休息 {}s'.format(i, next_rest_time)) # for j in range(next_rest_time): # sys.stdout.write('\r程序将在 {}s 后继续'.format(next_rest_time - j)) # sys.stdout.flush() # time.sleep(1) # print('\n继续') # i, next_rest, next_rest_time = (0, random.randrange(30, 100), # random.randrange(10, 60)) # 为了保证截图的时候应落稳了,多延迟一会儿,随机值防 ban time.sleep(random.uniform(0.9, 1.2)) action_func(resetAction, 1) action.sdkFinish(sys.argv[0])
def main(): """ main :return: """ print('程序版本号:{}'.format(VERSION)) print('激活窗口并按 CONTROL + C 组合键退出') debug.dump_device_info() screenshot.check_screenshot() while True: next_page() time.sleep(1) screenshot.pull_screenshot() resize_image('autojump.png', 'optimized.png', 1024 * 1024) with open('optimized.png', 'rb') as bin_data: image_data = bin_data.read() ai_obj = apiutil.AiPlat(AppID, AppKey) rsp = ai_obj.face_detectface(image_data, 0) if rsp['ret'] == 0: beauty = 0 for face in rsp['data']['face_list']: print(face) face_area = (face['x'], face['y'], face['x'] + face['width'], face['y'] + face['height']) print(face_area) img = Image.open("optimized.png") cropped_img = img.crop(face_area).convert('RGB') cropped_img.save(FACE_PATH + face['face_id'] + '.png') # 性别判断 if face['beauty'] > beauty and face['gender'] < 50: print("颜值不达标跳过!") beauty = face['beauty'] # 是个美人儿~关注点赞走一波 if beauty > BEAUTY_THRESHOLD: print('小姐姐还可以,点个赞!') thumbs_up() if beauty > BEAUTY_THRESHOLD + 10: print('要细细看来,很不错,关注一下!') follow_user() else: print(rsp) continue
def main2(): screenshot.check_screenshot() # im = screenshot.pull_screenshot2CV() # page = cv2.imread('resource/image/echoofredC.jpg') # if Moving.find_page(im,page): # print('page not find') # exit(1) while True: find_stage('SP3') start_stage() # choose_ship('heianjie') while True: im = screenshot.pull_screenshot2CV() pos = Moving.find_enemy(im) posx = pos adb.tap_scale(pos) time.sleep(4.5) while True: im = screenshot.pull_screenshot2CV() pos, val = Moving.attack(im) if val < 0.05: print('出击!') adb.tap_scale(pos) break else: pos, val = Moving.ambush(im) if val < 0.1: print('遭遇伏击!规避') TapButton.escape(im, adb) else: print('遭遇空袭!继续进行') # 继续 adb.tap_scale(posx) time.sleep(2.5) val = 1 while val > 0.05: print("判断是否战斗结束,若未能进入战斗状态,请手动进入战斗") time.sleep(1) im = screenshot.pull_screenshot2CV() pos, val = Moving.finished(im) adb.tap_scale(pos) time.sleep(0.5) adb.tap_scale((500, 300)) time.sleep(1.5) im = screenshot.pull_screenshot2CV() TapButton.confirm(im, adb) time.sleep(4.5)
def hot_videos(): """ main :return: """ print('程序版本号:{}'.format(VERSION)) print('激活窗口并按 CONTROL + C 组合键退出') debug.dump_device_info() screenshot.check_screenshot() while True: next_page() time.sleep(3) getVideoData()
def main(): """ 主函数 """ # op = yes_or_no('请确保手机打开了 ADB 并连接了电脑,' # '然后打开跳一跳并【开始游戏】后再用本程序,确定开始?') # if not op: # print('bye') # return print('程序版本号:{}'.format(VERSION)) debug.dump_device_info() screenshot.check_screenshot() i, next_rest, next_rest_time = (0, random.randrange(3, 10), random.randrange(5, 10))
def main(): """ 主函数 """ op = yes_or_no('请确保手机打开了 ADB 并连接了电脑,' '然后打开跳一跳并【开始游戏】后再用本程序,确定开始?') if not op: print('bye') return print('程序版本号:{}'.format(VERSION)) debug.dump_device_info() screenshot.check_screenshot() curJumpIndex, next_rest, next_rest_time = (0, random.randrange(3, 10), random.randrange(5, 10)) while True: screenshot.pull_screenshot() im = Image.open('./autojump.png') # 获取棋子位置(piece_x, piece_y)和 board 的位置(board_x, board_y) piece_x, piece_y, board_x, board_y = find_piece_and_board(im) # 获取当前时间作为debug备份的图片文件名,用于错误调试 curTime = int(time.time()) print(curTime, piece_x, piece_y, board_x, board_y) set_button_position(im) jump(math.sqrt((board_x - piece_x)**2 + (board_y - piece_y)**2)) if DEBUG_SWITCH: debug.save_debug_screenshot(curTime, im, piece_x, piece_y, board_x, board_y) debug.backup_screenshot(curTime) im.close() curJumpIndex += 1 if curJumpIndex == next_rest: print('已经连续打了 {} 下,休息 {}s'.format(curJumpIndex, next_rest_time)) for j in range(next_rest_time): sys.stdout.write('\r程序将在 {}s 后继续'.format(next_rest_time - j)) sys.stdout.flush() time.sleep(1) print('\n继续') curJumpIndex, next_rest, next_rest_time = (0, random.randrange( 30, 100), random.randrange( 10, 60)) # 为了保证截图的时候应落稳了,多延迟一会儿,随机值防 ban time.sleep(random.uniform(0.9, 1.2))
def main(): """ 主函数 """ op = yes_or_no('请确保手机打开了 ADB 并连接了电脑,' '然后打开跳一跳并【开始游戏】后再用本程序,确定开始?') if not op: print('bye') return print('程序版本号:{}'.format(VERSION)) debug.dump_device_info() screenshot.check_screenshot() i, next_rest, next_rest_time = (0, random.randrange(3, 20), random.randrange(2, 10)) flag_cout = 1 ##连跳计数 screen_size = configPy._get_screen_size() ##获取屏幕大小 screen_size_board_y_coefficient = int(GetMiddleStr(screen_size)) while True: time.sleep(random.random() * 5) ##每次操作时间不同 screenshot.pull_screenshot() im = Image.open('./autojump.png') # 获取棋子和 board 的位置 piece_x, piece_y, board_x, board_y = find_piece_and_board( im, flag_cout, screen_size_board_y_coefficient) ts = int(time.time()) print(ts, piece_x, piece_y, board_x, board_y) set_button_position(im) jump(math.sqrt((board_x - piece_x)**2 + (board_y - piece_y)**2)) if DEBUG_SWITCH: debug.save_debug_screenshot(ts, im, piece_x, piece_y, board_x, board_y) debug.backup_screenshot(ts) im.close() i += 1 if i == next_rest: print('已经连续打了 {} 下,休息 {}s'.format(i, next_rest_time)) for j in range(next_rest_time): sys.stdout.write('\r程序将在 {}s 后继续'.format(next_rest_time - j)) sys.stdout.flush() time.sleep(1) print('\n继续') i, next_rest, next_rest_time = (0, random.randrange(30, 100), random.randrange(10, 60)) # 为了保证截图的时候应落稳了,多延迟一会儿,随机值防 ban time.sleep(random.uniform(0.9, 1.2))
def main(): """ 主函数 """ #op = yes_or_no(u'请确保手机打开了 ADB 并连接了电脑,然后打开跳一跳并【开始游戏】后再用本程序,确定开始?') op = yes_or_no('Please ensure that adb is opened.') if not op: print('bye') return print(u'程序版本号:{}'.format(VERSION)) debug.dump_device_info() screenshot.check_screenshot() i, next_rest, next_rest_time = (0, random.randrange(3, 10), random.randrange(5, 10)) while True: screenshot.pull_screenshot() im = Image.open('./autojump.png') # 获取棋子和 board 的位置 piece_x, piece_y, board_x, board_y = find_piece_and_board(im) ts = int(time.time()) # print(ts, piece_x, piece_y, board_x, board_y) set_button_position(im) global last_distance global last_time print("\033[34;1m [-] ",last_distance,last_time,"\033[0m") distance = math.sqrt((board_x - piece_x) ** 2 + (board_y - piece_y) ** 2) last_distance = int(round(distance)) last_time = jump(distance) if DEBUG_SWITCH: debug.save_debug_screenshot(ts, im, piece_x,piece_y, board_x, board_y) debug.backup_screenshot(ts) im.close() i += 1 # if i == next_rest: # print(u'已经连续打了 {} 下,休息 {}s'.format(i, next_rest_time)) # for j in range(next_rest_time): # sys.stdout.write(u'\r程序将在 {}s 后继续'.format(next_rest_time - j)) # sys.stdout.flush() # time.sleep(1) # print(u'\n继续') # i, next_rest, next_rest_time = (0, random.randrange(30, 100), # random.randrange(10, 20)) # 为了保证截图的时候应落稳了,多延迟一会儿,随机值防 ban time.sleep(random.uniform(0.8, 1.3))
def __init__(self): print('====================begin load parameter====================') self.config = config.open_accordant_config() # 左上角分数以下的位置 self.under_game_score_y = self.config['under_game_score_y'] # 长按的时间系数,请自己根据实际情况调节 self.press_coefficient = self.config['press_coefficient'] # 二分之一的棋子底座高度,可能要调节 self.piece_base_height_1_2 = self.config['piece_base_height_1_2'] # 棋子的宽度,比截图中量到的稍微大一点比较安全,可能要调节 self.piece_body_width = self.config['piece_body_width'] self.MIN_DISTANCE = int(350 / float(self.press_coefficient)) self.MAX_DISTANCE = int(950 / float(self.press_coefficient)) print('====================load parameter success====================') screenshot.check_screenshot()
def answer_j(): print('进入答题页面') screenshot.check_screenshot() img = Image.open("./screenshot.png") old_question, old_choices0, old_choices1 = ocr.ocr_img_baidu(img, config) if old_question == 0: screenshot.tap_screen(500, 150) return print('题目:' + old_question) print('第一行选项:' + old_choices0) print('第二行选项:' + old_choices1) question = [] choices0 = [] choices1 = [] for i in range(len(old_question)): question.append(old_question[i]) for i in range(len(old_choices0)): choices0.append(map_list.get(old_choices0[i], old_choices0[i])) for i in range(len(old_choices1)): choices1.append(map_list.get(old_choices1[i], old_choices1[i])) choices0_len = len(choices0) every_len = 1080 / choices0_len / 2 already_choice_list = [] for c in question: tap_flag = False for i, a in enumerate(choices0): a_pos = str(0) + str(i) if a == c and a_pos not in already_choice_list: already_choice_list.append(a_pos) screenshot.tap_screen((i * 2 + 1) * every_len, 1480) tap_flag = True break if not tap_flag: for j, b in enumerate(choices1): b_pos = str(1) + str(j) if b == c and b_pos not in already_choice_list: already_choice_list.append(b_pos) screenshot.tap_screen((j * 2 + 1) * every_len, 1670) tap_flag = True break if tap_flag is False: print('存在找不到的字跳过题目' + old_question) screenshot.tap_screen(500, 150) break
def main(): """ 主函数 """ op = yes_or_no('请确保手机打开了 ADB 并连接了电脑,' '然后打开跳一跳并【开始游戏】后再用本程序,确定开始?') if not op: print('bye') return print('程序版本号:{}'.format(VERSION)) debug.dump_device_info() screenshot.check_screenshot() i, next_rest, next_rest_time = (0, random.randrange(3, 10), random.randrange(5, 10)) while True: screenshot.pull_screenshot() im = Image.open('./autojump.png') # img = cv2.imread("./autojump.png") # emptyImage = np.zeros(img.shape, np.uint8) # emptyImage2 = img.copy() # # cv2.imshow("Python+OpenCV", emptyImage2) # cv2.waitKey (0) # cv2.destroyAllWindows() # 获取棋子和 board 的位置 piece_x, piece_y, board_x, board_y = find_piece_and_board(im) ts = int(time.time()) print(ts, piece_x, piece_y, board_x, board_y) set_button_position(im) jump(math.sqrt((board_x - piece_x) ** 2 + (board_y - piece_y) ** 2)) if DEBUG_SWITCH: debug.save_debug_screenshot(ts, im, piece_x, piece_y, board_x, board_y) debug.backup_screenshot(ts) # im.close() i += 1 if i == next_rest: print('已经连续打了 {} 下,休息 {}s'.format(i, next_rest_time)) for j in range(next_rest_time): sys.stdout.write('\r程序将在 {}s 后继续'.format(next_rest_time - j)) sys.stdout.flush() time.sleep(1) print('\n继续') i, next_rest, next_rest_time = (0, random.randrange(30, 100), random.randrange(10, 60)) # 为了保证截图的时候应落稳了,多延迟一会儿,随机值防 ban time.sleep(random.uniform(0.9, 1))
def main(): """ 主函数 """ print('激活窗口并按 CONTROL + C 组合键退出') if DEBUG_SWITCH: print('DEBUG模式已开启') else: print('DEBUG模式已关闭') debug.dump_device_info() screenshot.check_screenshot() i, next_rest, next_rest_time = (0, random.randrange(3, 10), random.randrange(5, 10)) while True: image = screenshot.pull_screenshot() work_path = sys.path[0] template = cv2.imread(os.path.join(work_path, 'piece.png')) # 获取棋子和 board 的位置 piece_top_left, piece_bottom_right, piece_loc, board_loc = get_piece_board_loc( image, template) ts = int(time.time()) print("\ntime:{}, piece_loc:{}, board_loc:{}".format( ts, piece_loc, board_loc)) set_button_position(image) jump(piece_loc, board_loc) if DEBUG_SWITCH: debug.save_debug_screenshot(ts, image, piece_top_left, piece_bottom_right, piece_loc, board_loc) # debug.backup_screenshot(ts) i += 1 if i == next_rest: print('已经连续打了 {} 下,休息 {}秒'.format(i, next_rest_time)) for j in range(next_rest_time): sys.stdout.write('\r程序将在 {}秒 后继续'.format(next_rest_time - j)) sys.stdout.flush() time.sleep(1) print('\n继续') i, next_rest, next_rest_time = (0, random.randrange(30, 100), random.randrange(10, 60)) # 为了保证截图的时候应落稳了,多延迟一会儿,随机值防 ban time.sleep(random.uniform(1.2, 1.4))
def main(): """ main :return: """ print('程序版本号:{}'.format(VERSION)) print('激活窗口并按 CONTROL + C 组合键退出') debug.dump_device_info() screenshot.check_screenshot() while True: time.sleep(1) click_user() time.sleep(2) screenshot.pull_screenshot() back_up() next_page()
def main(): """ 主函数 """ op = yes_or_no('请确保手机打开了 ADB 并连接了电脑,' '然后打开跳一跳并【开始游戏】后再用本程序,确定开始?') if not op: print('bye') return print('程序版本号:{}'.format(VERSION)) debug.dump_device_info() screenshot.check_screenshot() i, next_rest, next_rest_time = (0, random.randrange(3, 10), random.randrange(5, 10)) while True: screenshot.pull_screenshot() im = Image.open('./autojump.png') # 获取棋子和 board 的位置 piece_x, piece_y, board_x, board_y = find_piece_and_board(im) ts = int(time.time()) print(ts, piece_x, piece_y, board_x, board_y) set_button_position(im) jump(math.sqrt((board_x - piece_x) ** 2 + (board_y - piece_y) ** 2)) if DEBUG_SWITCH: debug.save_debug_screenshot(ts, im, piece_x, piece_y, board_x, board_y) debug.backup_screenshot(ts) im.close() i += 1 if i == next_rest: print('已经连续打了 {} 下,休息 {}s'.format(i, next_rest_time)) for j in range(next_rest_time): sys.stdout.write('\r程序将在 {}s 后继续'.format(next_rest_time - j)) sys.stdout.flush() time.sleep(1) print('\n继续') i, next_rest, next_rest_time = (0, random.randrange(30, 100), random.randrange(10, 60)) # 为了保证截图的时候应落稳了,多延迟一会儿,随机值防 ban time.sleep(random.uniform(0.9, 1.2))
def main(): """ 主函数 """ op = yes_or_no('请确保手机打开了 ADB 并连接了电脑,' '然后打开跳一跳并【开始游戏】后再用本程序,确定开始?') if not op: print('bye') return print('程序版本号:{}'.format(VERSION)) debug.dump_device_info() screenshot.check_screenshot() i, next_rest, next_rest_time = (0, random.randrange(3, 10), random.randrange(5, 10)) j= 0 ################ 分数曲线公式 y_score=[] next_start=0 global start_score for i in range(total_step): each_score=target_score*(1-np.exp(-0.15*(1024.0/target_score)*i)) y_score.append(each_score) if start_score>each_score: next_start=i next_start+=1 #print(y_score) if start_score<y_score[0]: next_start=0 ################### with tf.Session() as sess: saver = tf.train.import_meta_graph('./resource/model/model.ckpt.meta') saver.restore(sess,tf.train.latest_checkpoint('./resource/model/')) graph = tf.get_default_graph() x = graph.get_tensor_by_name("x:0") logits = graph.get_tensor_by_name("logits_eval:0") #####################识别分数 while True: screenshot.pull_screenshot() im = Image.open('./autojump.png') ##比例系数 pix_w=im.size[0]*1.0/1080 pix_h=im.size[1] region=im.crop((0,pix_h*0.1,460*pix_w,pix_h*0.2)) region=region.convert('L') start_h,end_h,pixels_Widh=pixel_division(region,int(460*pix_w),int(pix_h*0.1)) if start_h==end_h: continue data = [] for i in range(len(pixels_Widh)-1): region1=region.crop((pixels_Widh[i],start_h,pixels_Widh[i+1],end_h)) region1.putdata(pross_data(region1)) str1="./region"+str(i)+".png" region1.save(str1) data1 = read_one_image(str1) data.append(data1) feed_dict = {x:data} classification_result = sess.run(logits,feed_dict) output = [] output = tf.argmax(classification_result,1).eval() m_score="" for i in range(len(output)): m_score+=strint(output[i]) if m_score=="": continue m_score=int(m_score) print('score:{}'.format(m_score)) #################################### # 获取棋子和 board 的位置 print(j) piece_x, piece_y, board_x, board_y = find_piece_and_board(im) ts = int(time.time()) print(ts, piece_x, piece_y, board_x, board_y) set_button_position(im) if m_score > y_score[next_start]: ##自动结束这一次 print("----------------") jump(math.sqrt((board_x - piece_x) ** 2 + (board_y - piece_y) ** 2)*5) next_start+=1 time.sleep(5*random.random()) if next_start >len(y_score): break jump(math.sqrt((board_x - piece_x) ** 2 + (board_y - piece_y) ** 2)) if DEBUG_SWITCH: debug.save_debug_screenshot(ts, im, piece_x, piece_y, board_x, board_y) debug.backup_screenshot(ts) im.close() i += 1 j += 1 if i == next_rest: print('已经连续打了 {} 下,休息 {}s'.format(i, next_rest_time)) for j in range(next_rest_time): sys.stdout.write('\r程序将在 {}s 后继续'.format(next_rest_time - j)) sys.stdout.flush() time.sleep(1) print('\n继续') i, next_rest, next_rest_time = (0, random.randrange(30, 100), random.randrange(10, 60)) # 为了保证截图的时候应落稳了,多延迟一会儿,随机值防 ban time.sleep(random.uniform(0.9, 1.2))
# -*- coding: utf-8 -*- # @Author : Skye # @Time : 2018/1/8 20:38 # @desc : 答题闯关辅助,截屏 ,OCR 识别,百度搜索 from PIL import Image from common import screenshot, ocr, methods from threading import Thread import time while True: # 截图 screenshot.check_screenshot() img = Image.open("./screenshot.png") # 文字识别 question, choices = ocr.ocr_img(img) # t = time.clock() # 用不同方法输出结果,取消某个方法在前面加上# # # 打开浏览器方法搜索问题 # methods.run_algorithm(0, question, choices) # # 将问题与选项一起搜索方法,并获取搜索到的结果数目 # methods.run_algorithm(1, question, choices) # # 用选项在问题页面中计数出现词频方法 # methods.run_algorithm(2, question, choices) # 多线程