def dog(): sets = Settings('kill') img = cv2.imread(r'images\\login\\again.png') times = 1 max_times = 30 while True: print('——————第 %d 次 次元觉醒 自动开始——————' % times) # 命令1:在手机上截图step.png为图片名 cmd1 = r"adb shell /system/bin/screencap -p /sdcard/step.png" # 命令2:将图片保存到电脑C:\Users\THINK\PycharmProjects\Com2us\images\temp\step.png为要保存到电脑的路径 cmd2 = r"adb pull /sdcard/step.png C:\Users\THINK\PycharmProjects\Com2us\images\temp\step.png" screen = ScreenShot() screen.screen(cmd1) screen.save_computer(cmd2) # 传入截图 template = cv2.imread(r'images\\temp\\step.png') if Base.match(img, template) > 0.9: # 再来一次坐标 again = Base.get_rand_xy(sets.again_x, sets.again_y) # 点击再来一次 Base.click(*again) Base.get_rand_time(120, 180) Base.click(*Base.get_rand_xy(sets.start_x, sets.start_y)) Base.get_rand_time(2, 4) Base.click(*Base.get_rand_xy([450, 490], [320, 340])) Base.get_rand_time(2, 4) Base.click(*Base.get_rand_xy(sets.prize_x, sets.prize_y)) Base.get_rand_time(2, 4) Base.click(*Base.get_rand_xy(sets.activity_x, sets.activity_y)) times += 1 print('——————第 %d 次自动结束——————' % (times - 1)) if times > max_times: break
def underworld(self): template = Base.get_screen() img = Base.get_img(r'..\images\login\fight.png') while Base.match(img, template) < 0.9: Base.get_rand_time(2, 3) Base.get_screen() Base.click(*Base.get_rand_xy(self.fight_x, self.fight_y)) pass
def com2us_login(self, apk_path): """ :return: """ apk_info = self.info.get_package_and_activity(apk_path) # 初始化活动页面以及登录主页面 login = Base.get_img(r'..\images\login\login.png') login2 = Base.get_img(r'..\images\login\login2.png') # 打开app driver = Base(self.cap) driver.open_app(*apk_info) driver.implicitly_wait(50) # 第一次截图 template = Base.get_screen() Base.get_rand_time(3, 4) # 每30截一次图,直到进入登入界面,停止截图 while Base.match(login, template) < 0.9: template = Base.get_screen() Base.get_rand_time(10, 20) print(Base.match(login2, template)) if Base.match(login2, template) < 0.9: continue else: print('开始关闭活动页面') click = Base.get_rand_xy(self.login_activity_x, self.login_activity_y) Base.click(*click) Base.get_rand_time(1, 2) Base.click(*Base.get_rand_xy([460, 470], [430, 460])) print('进入主界面') print('关闭邮箱') Base.get_rand_time(1, 2) Base.click(*Base.get_rand_xy(self.mail_x, self.mail_y)) print('关闭限时优惠') Base.get_rand_time(1, 2) Base.click(*Base.get_rand_xy(self.price_x, self.price_y))
def tower(): sets = Settings() img = cv2.imread(r'images\\baita\\tower.png') times = 1 max_times = 74 while True: print('——————第 %d 层塔 开始——————' % times) # 命令1:在手机上截图step.png为图片名 cmd1 = r"adb shell /system/bin/screencap -p /sdcard/step.png" # 命令2:将图片保存到电脑C:\Users\THINK\PycharmProjects\Com2us\images\temp\step.png为要保存到电脑的路径 cmd2 = r"adb pull /sdcard/step.png C:\Users\THINK\PycharmProjects\Com2us\images\temp\step.png" screen = ScreenShot() screen.screen(cmd1) screen.save_computer(cmd2) # 传入截图 template = cv2.imread(r'images\\temp\\step.png') if Base.match(img, template) > 0.9: # 再来一次坐标 again = Base.get_rand_xy(sets.again_x, sets.again_y) # 点击再来一次 Base.click(*again) Base.get_rand_time(5, 6) # 点击开始战斗 Base.click(*Base.get_rand_xy([750, 870], [360, 410])) Base.get_rand_time(120, 180) # 点击遮罩 Base.click(*Base.get_rand_xy(sets.start_x, sets.start_y)) Base.get_rand_time(2, 4) # 点击箱子 Base.click(*Base.get_rand_xy([450, 490], [320, 340])) Base.get_rand_time(2, 4) # 点击确认 Base.click(*Base.get_rand_xy([430, 530], [380, 430])) Base.get_rand_time(2, 4) times += 1 print('——————第 %d 层塔 结束——————' % (times - 1)) if times > max_times: break
desired_caps["platformName"] = 'Android' desired_caps['platformVersion'] = '5.1' desired_caps['deviceName'] = 'emulator-5554' # desired_caps['appPackage'] = 'com.android.settings' # desired_caps['appActivity'] = '.HWSettings' desired_caps['appPackage'] = pages.app_package desired_caps['appActivity'] = pages.app_activity desired_caps['unicodeKeyboard'] = True desired_caps['resetKeyboard'] = True cls.__app_driver = appium.webdriver.Remote( 'http://127.0.0.1:4723/wd/hub', desired_caps) return cls.__app_driver @classmethod def quit_app_driver(cls): if cls.__app_driver: cls.__app_driver.quit() cls.__app_driver = None if __name__ == '__main__': driver = GetDriver.get_app_driver() print(driver) el = Base(driver).base_get_element(pages.app_username) el.click() sleep(2) msg = "13812345678" input(msg, driver) sleep(5) GetDriver.quit_app_driver()
def experiences(): """ 刷火山口 :return: """ sets = Settings('experience') img = cv2.imread(r'images\\login\\again2.png') times = 1 max_times = 50 while True: print('——————第 %d 次 经验副本 自动开始——————' % times) # 传入截图 Base.get_rand_time(2, 4) template = Base.get_screen() if Base.match(img, template) > 0.9: # 再来一次坐标 again = Base.get_rand_xy(sets.again_x, sets.again_y) # 点击再来一次 Base.click(*again) Base.get_rand_time(60, 80) # 点击遮罩 Base.click(*Base.get_rand_xy(sets.start_x, sets.start_y)) Base.get_rand_time(2, 4) # 点击箱子 Base.click(*Base.get_rand_xy([450, 490], [320, 340])) Base.get_rand_time(2, 4) # 点击确认按钮 Base.click(*Base.get_rand_xy([440, 520], [430, 470])) Base.get_rand_time(2, 4) # 出售符文 Base.click(*Base.get_rand_xy([350, 440], [420, 450])) Base.get_rand_time(2, 4) # 确认出售符文 Base.click(*Base.get_rand_xy([340, 440], [310, 340])) Base.get_rand_time(2, 4) # 活动硬币点击 Base.click(*Base.get_rand_xy(sets.activity_x, sets.activity_y)) times += 1 else: Base.get_rand_time(20, 30) # 点击遮罩 Base.click(*Base.get_rand_xy(sets.start_x, sets.start_y)) Base.get_rand_time(2, 4) # 点击箱子 Base.click(*Base.get_rand_xy([450, 490], [320, 340])) Base.get_rand_time(2, 4) # 点击确认按钮 Base.click(*Base.get_rand_xy([440, 520], [430, 470])) Base.get_rand_time(2, 4) # 出售符文 Base.click(*Base.get_rand_xy([350, 440], [420, 450])) Base.get_rand_time(2, 4) # 确认出售符文 Base.click(*Base.get_rand_xy([340, 440], [310, 340])) Base.get_rand_time(2, 4) # 活动硬币点击 Base.click(*Base.get_rand_xy(sets.activity_x, sets.activity_y)) times += 1 print('——————第 %d 次自动结束——————' % (times - 1)) if times > max_times: break