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 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(): ''' 主函数 ''' op = yes_or_no('请确保手机打开了 ADB 并连接了电脑,然后打开跳一跳并【开始游戏】后再用本程序,确定开始?') if not op: print('bye') return print('程序版本号:{}'.format(VERSION)) debug.dump_device_info() check_screenshot() i, next_rest, next_rest_time = 0, random.randrange(3, 10), random.randrange( 5, 10) while True: 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) time.sleep(random.uniform(0.9, 1.2)) # 为了保证截图的时候应落稳了,多延迟一会儿,随机值防 ban
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 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 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(): ''' 主函数 ''' op = yes_or_no('请确保手机打开了 ADB 并连接了电脑,然后打开跳一跳并【开始游戏】后再用本程序,确定开始?') if not op: print('bye') return print('程序版本号:{}'.format(VERSION)) debug.dump_device_info() check_screenshot() i, next_rest, next_rest_time = 0, random.randrange(3, 10), random.randrange(5, 10) while True: 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) 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) time.sleep(random.uniform(1.5, 2.0)) # 为了保证截图的时候应落稳了,多延迟一会儿,随机值防 ban
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(): ''' 主函数 ''' print('程序版本号:{}'.format(VERSION)) debug.dump_device_info() check_screenshot() i, next_rest, next_rest_time = 0, random.randrange(3, 10), random.randrange( 5, 10) while True: 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) i += 1 time.sleep(random.uniform(0.3, 1.9)) # 为了保证截图的时候应落稳了,多延迟一会儿,随机值防 ban
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(): """ 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 # 设置最大分数 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 main(): ''' 主函数 ''' # op = yes_or_no('请确保手机打开了 ADB 并连接了电脑,然后打开跳一跳并【开始游戏】后再用本程序,确定开始?') # if not op: # print('bye') # return # 初始化AI ai.init() print('程序版本号:{}'.format(VERSION)) debug.dump_device_info() check_screenshot() i, next_rest, next_rest_time = 0, random.randrange(3, 10), random.randrange( 5, 10) while True: 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) press_time = jump( math.sqrt((board_x - piece_x)**2 + (board_y - piece_y)**2)) # 在跳跃落下的瞬间 摄像机移动前截图 这个参数要自己校调 time.sleep(0.2) pull_screenshot_temp() im_temp = Image.open('./autojump_temp.png') temp_piece_x, temp_piece_y = find_piece(im_temp) debug.computing_error(press_time, board_x, board_y, piece_x, piece_y, temp_piece_x, temp_piece_y) if debug_switch: debug.save_debug_screenshot(ts, im, piece_x, piece_y, board_x, board_y) debug.save_debug_screenshot(ts, im_temp, temp_piece_x, temp_piece_y, board_x, board_y) # debug.backup_screenshot(ts) i = 0 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) time.sleep(random.uniform(0.5, 0.6)) # 为了保证截图的时候应落稳了,多延迟一会儿,随机值防 ban
def main(): """ main :return: """ print('程序版本号:{}'.format(VERSION)) print('激活窗口并按 CONTROL + C 组合键退出') debug.dump_device_info() screenshot.check_screenshot() #TencentRun() FacePPRun()
def main(): log.info('激活窗口并按 CONTROL + C 组合键退出') debug.dump_device_info() cpt = config.Component() components = cpt.load() step = config.Step() steps = step.load() task = robot.Task(components, steps) tasks = task.gen_tasks() robot_man = robot.Robot(tasks) robot_man.run() return 0
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 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 # 初始化AI ai.init() print('程序版本号:{}'.format(VERSION)) debug.dump_device_info() check_screenshot() i, next_rest, next_rest_time = 0, random.randrange(3, 10), random.randrange(5, 10) while True: 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) press_time = jump(math.sqrt((board_x - piece_x) ** 2 + (board_y - piece_y) ** 2)) # 在跳跃落下的瞬间 摄像机移动前截图 这个参数要自己校调 time.sleep(0.2) pull_screenshot_temp() im_temp = Image.open('./autojump_temp.png') temp_piece_x, temp_piece_y = find_piece(im_temp) debug.computing_error(press_time, board_x, board_y, piece_x, piece_y, temp_piece_x, temp_piece_y) if debug_switch: debug.save_debug_screenshot(ts, im, piece_x, piece_y, board_x, board_y) debug.save_debug_screenshot(ts, im_temp, temp_piece_x, temp_piece_y, board_x, board_y) # debug.backup_screenshot(ts) i = 0 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) time.sleep(random.uniform(0.5, 0.6)) # 为了保证截图的时候应落稳了,多延迟一会儿,随机值防 ban
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 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('请确保手机打开了 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(): ''' 主函数 ''' op = yes_or_no('请确保手机打开了 ADB 并连接了电脑,后再用本程序,确定开始?') if not op: print('bye') return #print('程序版本号:{}'.format(VERSION)) debug.dump_device_info() check_screenshot() #i, next_rest, next_rest_time = 0, random.randrange(3, 10), random.randrange(5, 10) while True: print(time.strftime('%H:%M:%S',time.localtime(time.time()))) print(get_answer()) time.sleep(1)
def main(): ai.init() print('程序版本号:{}'.format(VERSION)) debug.dump_device_info() check_screenshot() i, next_rest, next_rest_time = 0, random.randrange(3, 10), random.randrange( 5, 10) while True: 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) press_time = jump( math.sqrt((board_x - piece_x)**2 + (board_y - piece_y)**2)) # 在跳跃落下的瞬间 摄像机移动前截图 这个参数要自己校调 time.sleep(0.04) pull_screenshot_temp() im_temp = Image.open('./autojump_temp.png') temp_piece_x, temp_piece_y = find_piece(im_temp) debug.computing_error(press_time, board_x, board_y, piece_x, piece_y, temp_piece_x, temp_piece_y) if debug_switch: debug.save_debug_screenshot(ts, im, piece_x, piece_y, board_x, board_y, "d") debug.save_debug_screenshot(ts, im_temp, temp_piece_x, temp_piece_y, board_x, board_y, "t") # debug.backup_screenshot(ts) # i = 0 # 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(1, 5), random.randrange(2, 6) time.sleep(random.uniform(1.0, 1.5)) # 为了保证截图的时候应落稳了,多延迟一会儿,随机值防 ban
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('输入y确定开始,输入n退出程序') 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 read(self, devices): # 打开刷宝 for dName in devices: os.system( "adb -s %s shell am start -n com.jm.video/.ui.main.SplashActivity" % dName) # 等待 time.sleep(10) appstart = time.time() count = 0 # 主程序逻辑 执行时长小于总时长 while (time.time() - appstart) < self.apptime: count += 1 print("阅读%d次" % count) # 随机阅读时间 readtime = random.randint(3, 6) # 记录开始时间 start = time.time() # 每间隔1s循环向下/向上翻页,持续固定时长X while (time.time() - start) < readtime: time.sleep(3) x = random.randint(350, 450) y1 = random.randint(800, 850) y2 = y1 - random.randint(600, 610) # 设备循环执行 for dName in devices: debug.dump_device_info() screenshot.check_screenshot(dName) distrub.init(dName) os.system("adb -s " + dName + " shell input swipe %d %d %d %d 1500 &" % (x, y1, x, y2)) # 后台执行 小米800-200 print("阅读完成:刷宝") # 关闭刷宝 for dName in devices: os.system("adb -s %s shell am force-stop com.jm.video" % dName)
def main(): """ 主函数 """ 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: im = screenshot.pull_screenshot() # 获取棋子和 board 的位置 piece_x, piece_y, board_x, board_y, delta_piece_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), delta_piece_y) 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('已经连续打了 {} 下,休息 {}秒'.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(): """ 主函数 """ 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))