def __init__(self, ast, real=True): GenericASTTraversal.__init__(self, ast) self.output = [] self.automator = Automator(real) self.postorder() self.automator.flush()
def __init__(self, ast, real = True): GenericASTTraversal.__init__(self, ast) self.output = [] self.automator = Automator(real) self.postorder() self.automator.flush()
class TestAutomator(unittest.TestCase): def setUp(self): self.auto = Automator() def test_menor_de_dez(self): self.assertEqual(self.auto.translate(5),'cinco') def test_11_19(self): self.assertEqual(self.auto.translate(15),'quinze') def test_dezena_2(self): self.assertEqual(self.auto.translate(53),'cinquenta e tres') self.assertEqual(self.auto.translate(87),'oitenta e sete') def test_centena(self): self.assertEqual(self.auto.translate(356),'trezentos e cinquenta e seis') def test_centena_11_19(self): self.assertEqual(self.auto.translate(519), 'quinhentos e dezenove')
from automator import Automator # Loading scripts to execute in the list sequentially scripts = ['script.py', 'zip_extractor.py'] # Initializing Automator with time paramaeters Automator(scripts, 'thursday', '14:00').start()
from automator import Automator import sys if __name__ == '__main__': config = { "device": { "host": "127.0.0.1", #安卓模拟器adb通讯的ip地址 "port": "7555" #安卓模拟器adb通讯的端口,mumu模拟器默认为7555 }, "points": { #左下建筑和右上建筑的中心的坐标 "left": 200, #左下建筑的x坐标 "bottom": 820, #左下建筑的y坐标 "right": 530, #右上建筑的x坐标 "top": 310 #右上建筑的y坐标 }, "target_level": 3 #小火车拉货等级,1-3,1表示全部都拉,2表示紫色和橙色,3表示橙色,需要配合文件名 } targetPath = "targets" if len(sys.argv) > 1: targetPath = sys.argv[1] # 连接 adb 。 instance = Automator(config, targetPath) # 启动脚本。 instance.start()
from automator import Automator if __name__ == '__main__': # 升级建筑列表, 实际升级是随机从这个列表中挑一个升级 up_list = [(1,5),(2,5),(3,5),(4,5),(5,5),(6,5),(7,5),(8,5),(9,5)] # 雨露均沾 # up_list = [(1,1),(1,1),(1,1),(4,3)] # 75%的概率1号升级1次, 25%的概率4号升级3次 # up_list = [(8,1),(9,1)] # 这个号建筑升级1次, 那个号建筑升级1次 # 收货过滤列表 harvest_filter = [1,2,3,4,5,6,7,8,9] # 收取这些号建筑的货物 # adb设备列表 Device1 = 'QV7039V30X' Device2 = 'CB512BC4ZL' Device1Net = '10.21.20.105' Device2Net = '10.21.59.70' MuMu = '127.0.0.1:7555' policy = True # 是否自动升级政策 task = True # 是否自动完成任务 speed_up = False#是否自动重启加速刷火车 instance = Automator(MuMu, up_list, harvest_filter,auto_policy=policy,auto_task=task,speedup=speed_up) # 启动脚本。 instance.start()
def main(kb): # 连接 adb 。 instance = Automator('emulator-5554', kb) # 启动脚本。 instance.start()
from automator import Automator from target import TargetType if __name__ == '__main__': # 声明货物要移动到的建筑 ID 。 targets = { TargetType.Chair: 1, TargetType.Wood: 7, TargetType.Bottle: 4, TargetType.Vegetable: 5, TargetType.Box: 2, TargetType.Food: 8 TargetType.Sofa: 2, TargetType.Chicken: 4, TargetType.Ore: 8 } # 连接 adb 。 instance = Automator('127.0.0.1:7555', targets) # 启动脚本。 instance.start()
class ExecuteCommands(GenericASTTraversal): def __init__(self, ast, real=True): GenericASTTraversal.__init__(self, ast) self.output = [] self.automator = Automator(real) self.postorder() self.automator.flush() def n_char(self, node): self.automator.key(node.meta[0]) def n_raw_char(self, node): self.automator.raw_key(node.meta[0]) def n_movement(self, node): self.automator.key(node.meta[0].type) def n_sequence(self, node): for c in node.meta[0]: self.automator.raw_key(c) def n_word_sequence(self, node): n = len(node.children) for i in range(0, n): word = node.children[i].meta for c in word: self.automator.raw_key(c) if (i + 1 < n): self.automator.raw_key('space') def n_null(self, node): pass def n_repeat(self, node): xdo = self.automator.xdo_list[-1] for n in range(1, node.meta[0]): self.automator.xdo(xdo) def default(self, node): # for child in node.children: # self.automator.execute(child.command) pass
formatter = logging.Formatter( '%(asctime)s - %(name)s - %(levelname)s - %(message)s') handler.setFormatter(formatter) logger.addHandler(handler) if __name__ == '__main__': # 安卓本地运行 # device = 'http://0.0.0.0:7912' # pc运行,adb devices 命令后得出的结果 device = '53aac21b' # 是否有app九宫锁 is_app_lock = False # 九宫锁解锁的点的坐标,可以通过Weditor来获取每个点的相对坐标 lock_points = [(0.235, 0.575), (0.494, 0.571), (0.756, 0.859), (0.243, 0.863)] # 是否开启蚂蚁森林自动收能量任务 is_ant_forest_on = False # 是否开启支付宝app2019双11活动自动任务 is_zhi_fu_bao_to_2019_on = False # 是否开启淘宝app2019双11活动自动任务 is_tao_bao_to_2019_on = True # 是否开启支付宝app领积分自动任务 is_zhi_fu_bao_gain_points_on = False instance = Automator(device, is_app_lock, lock_points, is_ant_forest_on, is_zhi_fu_bao_to_2019_on, is_tao_bao_to_2019_on, is_zhi_fu_bao_gain_points_on) # 启动脚本。 instance.start()
from automator import Automator if __name__ == '__main__': # 连接 adb 。 instance = Automator('127.0.0.1:62001') # 启动脚本。 instance.start()
# TargetType.Oil: 8, # # TargetType.Food: 8, # TargetType.Iron: 8, # TargetType.Grass:9, # TargetType.Tool: 8, # TargetType.Quilt: 9, TargetType.Wardrobe: 1, TargetType.Coal: 9, # TargetType.Bottle: 5, TargetType.Vegetable: 4, TargetType.Blanket: 2, TargetType.Food: 7, TargetType.Chicken: 6, TargetType.Cotton: 8, TargetType.Sofa: 3 } # 此处的设备换成你自己的 instance = Automator('3204539b871a2181', targets) instance.start() # 如果火车不再送货,可以使用下面这个函数,仅仅收取金币。 # instance.grabOnly()
def setUp(self): self.auto = Automator()
from automator import Automator from target import TargetType if __name__ == '__main__': # 声明货物要移动到的建筑 ID 。 targets = { TargetType.Chair: 1, TargetType.Wood: 7, TargetType.Bottle: 4, TargetType.Vegetable: 5, TargetType.Box: 2, TargetType.Food: 8 } # 连接 adb 。 instance = Automator('emulator-5554', targets) # 启动脚本。 instance.start()
def main(kb): # 连接 adb 。 instance = Automator('127.0.0.1:7555', kb) # 启动脚本。 instance.start()
class ExecuteCommands(GenericASTTraversal): def __init__(self, ast, real = True): GenericASTTraversal.__init__(self, ast) self.output = [] self.automator = Automator(real) self.postorder() self.automator.flush() def n_char(self, node): self.automator.key(node.meta[0]) def n_raw_char(self, node): self.automator.raw_key(node.meta[0]) def n_movement(self, node): self.automator.key(node.meta[0].type) def n_sequence(self, node): for c in node.meta[0]: self.automator.raw_key(c) def n_word_sequence(self, node): n = len(node.children) for i in range(0, n): word = node.children[i].meta for c in word: self.automator.raw_key(c) if(i + 1 < n): self.automator.raw_key('space') def n_null(self, node): pass def n_repeat(self, node): xdo = self.automator.xdo_list[-1] for n in range(1, node.meta[0]): self.automator.xdo(xdo) def default(self, node): # for child in node.children: # self.automator.execute(child.command) pass