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 __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 __init__(): #初始化 try: from common import config except ImportError: print('[ERROR] Please run in the root directory') exit(-1) global _global_dict _global_dict = {} config = config.open_accordant_config("config.json") _global_dict['host'] = config['host'] _global_dict['user'] = config['user'] _global_dict['password'] = config['password'] _global_dict['dbname'] = config['dbname'] _global_dict['port'] = config['port']
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 set_ime(self, ime): config_data = config.open_accordant_config('common') name = config_data[ime]['name'] # 1.检测输入法是否安装 cmd = 'shell ime list -a' output = self.adb.run(cmd) index = output.find(name, 0, len(output)) if index < 0: print('未安装{}输入法,安装后使用!'.format(name)) exit(0) # 2.输入法设置 cmd = 'shell ime set {}'.format(name) output = self.adb.run(cmd) index = output.find('selected', 0, len(output)) if index < 0: print('设置{}输入法失败,手动设置后使用'.format(name)) exit(0)
import random from six.moves import input try: from common import ai, debug, config, UnicodeStreamFilter from common.auto_adb import auto_adb except Exception as ex: print(ex) print('请将脚本放在项目根目录中运行') print('请检查项目根目录中的 common 文件夹是否存在') exit(1) adb = auto_adb() VERSION = "1.1.4" debug_switch = True # debug 开关,需要调试的时候请改为:True config = config.open_accordant_config() # Magic Number,不设置可能无法正常执行,请根据具体截图从上到下按需设置,设置保存在 config 文件夹中 under_game_score_y = config['under_game_score_y'] press_coefficient = config['press_coefficient'] # 长按的时间系数,请自己根据实际情况调节 piece_base_height_1_2 = config['piece_base_height_1_2'] # 二分之一的棋子底座高度,可能要调节 piece_body_width = config['piece_body_width'] # 棋子的宽度,比截图中量到的稍微大一点比较安全,可能要调节 screenshot_way = 2 def pull_screenshot(): process = subprocess.Popen('adb shell screencap -p', shell=True, stdout=subprocess.PIPE) screenshot = process.stdout.read() if sys.platform == 'win32': screenshot = screenshot.replace(b'\r\n', b'\n')
from common.auto_adb import auto_adb except Exception as ex: print(ex) print('请将脚本放在项目根目录中运行') print('请检查项目根目录中的 common 文件夹是否存在') exit(1) adb = auto_adb() VERSION = "1.1.4" # DEBUG 开关,需要调试的时候请改为 True,不需要调试的时候为 False DEBUG_SWITCH = False # Magic Number,不设置可能无法正常执行,请根据具体截图从上到下按需 # 设置,设置保存在 config 文件夹中 config = config.open_accordant_config() under_game_score_y = config['under_game_score_y'] # 长按的时间系数,请自己根据实际情况调节 press_coefficient = config['press_coefficient'] # 二分之一的棋子底座高度,可能要调节 piece_base_height_1_2 = config['piece_base_height_1_2'] # 棋子的宽度,比截图中量到的稍微大一点比较安全,可能要调节 piece_body_width = config['piece_body_width'] target_score=1024 ##目标分数 total_step=30 ##达到目标次数所需游戏次数 start_score=100 ##设置第一次分数(目前分数) def set_button_position(im):
# -*- coding: utf-8 -*- ''' 各种AI接口调用 ''' import requests from requests import RequestException from aip import AipOcr from common import config from common import TencentAPI from common.TencentAPIMsg import TencentAPIMsg config = config.open_accordant_config('common') # 腾讯AI配置,尽量自己去申请APPID、APPKEY def qq_ai_set(): APPID = config['qq_ai']['APP_ID'] APPKEY = config['qq_ai']['API_KEY'] return APPID, APPKEY # 腾讯通用ocr def qq_orc_general(image): (APPID, APPKEY) = qq_ai_set() tx = TencentAPIMsg(APPID, APPKEY) Req_Dict = {} Req_Dict['image'] = tx.get_img_base64str('./tmp/screen.png') url = TencentAPI.TencentAPI['ocr_generalocr']['APIURL'] tx.init_req_dict(req_dict=Req_Dict) resp = requests.post(url, data=Req_Dict) # TODO:
# -*- coding: utf-8 -*- ''' create by: 小宝 mail: [email protected] create date: 2019.8.18 Purpose: hah ''' import sys from common import config config = config.open_accordant_config('doyin') main_activity = "com.ss.android.ugc.aweme/com.ss.android.ugc.aweme.main.MainActivity" actions = [{ "step": 1, "desc": "打开app", "type": "open", "main_activity": main_activity, }, { "step": 2, "desc": "截屏识图,判断符合后点赞", "type": "custom", "current": main_activity }, { "step": 3, "desc": "翻页", "type": "swipe", "x1": config['center_point']['x'], "y1": config['center_point']['y'], "x2": config['center_point']['x'], "y2": config['center_point']['y'] - config['center_point']['ry'],