def swipe_2_getpoint1(self, re_scale=False): if re_scale: self.g_swipe_times = 0 self.swipe2Top() pass x = 0 y = 0 while True: loge("当前滑动次数:{}".format(self.g_swipe_times)) input_data = self.get_input_num("请输入操作(1下页 2定点 3重置 0退出):", [0, 1, 2, 3]) if input_data == 1: self.swipeVNxt5_1() self.g_swipe_times += 1 continue pass if input_data == 2: x, y = self.get_point() continue pass if input_data == 3: self.swipe2Top() self.g_swipe_times = 0 continue pass break pass return x, y, self.g_swipe_times pass
def swipe_h_times(self, ptime=1, times=50): loge("横向滑动") for i in range(times): self.sleep(ptime) self.swipeHNxtPage() loge("下一页" + str(i)) pass pass
def goTaskCenter(self): loge("去任务中心") self.click(self.screenVo.center_x, self.screenVo.bottomDp(26)) self.sleep(8) self.swipeVPrePage() self.swipeVPrePage() self.swipeVPrePage() pass
def openWait(self): loge("开启抖音极速版等待") self.sleep(10) self.back() for i in range(5): self.sleep(5) self.back() self.swipeVNxtPage() loge("视频下一页") pass pass
def _choose_device(connect_devices): i = 0 for res in connect_devices: loge("编号:" + str(i) + " 设备:" + res) i += 1 pass choose_device_pos = input("请输入设备编号(其他刷新):") if not choose_device_pos.isdigit(): return choose_device_pos = int(choose_device_pos) if choose_device_pos >= len(connect_devices): return if choose_device_pos < 0: return return connect_devices[choose_device_pos] pass
def toAd(self, lookTime): loge("看广告") b = self.checkActivity("抖音广告") if not b: return pass while True: ffff pass loge(lookTime + "秒") self.sleep(lookTime) self.back() self.back() self.sleep(2.5) pass
def pause(self, info="none"): messagebox.showinfo(self.deviceVo.device_w,info) # # popen返回文件对象,跟open操作一样 # cmd = r'echo "pause {}:{} 暂停" >log.txt'.format(self.deviceVo.device_w, info) # with os.popen(cmd, 'r') as f: # text = f.read() # # logd(text) # # cmd = r'start log.txt' # with os.popen(cmd, 'r') as f: # text = f.read() # # logd(text) cmd = r'pause' with os.popen(cmd, 'r') as f: text = f.read() # logd(text) loge("继续运行") pass
def baoxiang(self): vo = self.getTaskDb().select_task(g_app_name, "baoxiang") if vo is None: vo = TaskVo() vo.device = self.deviceVo.device_u vo.task_app = g_app_name vo.task_name = "baoxiang" vo.task_time_jiange = 1205 pass if int(time.time()) < vo.task_finish + vo.task_time_jiange: return pass self.goTaskCenter() loge("滑动到宝箱-点击") self.swipe_click(g_app_name, g_point_name_tap_baoxiang_task) loge("看广告任务") self.toAd(36) loge("退出去赚钱页面") self.back() vo.task_finish = int(time.time()) self.getTaskDb().save(vo) pass
def get_devices(): # popen返回文件对象,跟open操作一样 with os.popen(r'adb devices', 'r') as f: text = f.read() logd(text) # 打印cmd输出结果 # 输出结果字符串处理 s = text.split("\n") # 切割换行 result = [x for x in s if x != ''] # 列生成式去掉空 logd(result) connect_devices = [] # 获取设备名称 for res in result: dev = res.split("\tdevice") if len(dev) >= 2: connect_devices.append(dev[0]) if not connect_devices: loge('无设备连接') else: loge('查询连接设备完成') return connect_devices pass
def swipe_v_times(self, ptime=5, ltime=120): loge("竖向滑动") start_time = self.getTime() while True: self.sleep(ptime) self.swipeVNxtPage() loge("下一页") end_time = self.getTime() # 判断是否已经运行三分钟 if end_time - start_time >= ltime: loge("退出") return pass pass pass
def liulanshangpin(self): vo = self.getTaskDb().select_task(g_app_name, "liulanshangpin") if vo is None: vo = TaskVo() vo.device = self.deviceVo.device_u vo.task_app = g_app_name vo.task_name = "liulanshangpin" vo.task_time_jiange = 600 vo.task_times = 3 vo.task_time_use = 35 pass allcount = self.getRecordDb().count(vo.device, vo.task_app, vo.task_name) if allcount >= vo.task_times: return pass if int(time.time()) < vo.task_finish + vo.task_time_jiange: return pass self.goTaskCenter() loge("滑动到浏览商品-点击") self.swipe_click(g_app_name, g_point_name_tap_liulanshangpin_task) loge("浏览商品") self.swipe_v_times(ptime=3, ltime=vo.task_time_use) loge("退出去赚钱页面") self.back() vo.task_finish = int(time.time()) self.getTaskDb().save(vo) self.getRecordDb().insert(vo) pass
def kanxiaoshuo(self): vo = self.getTaskDb().select_task(g_app_name, "kanxiaoshuo") if vo is None: vo = TaskVo() vo.device = self.deviceVo.device_u vo.task_app = g_app_name vo.task_name = "kanxiaoshuo" pass now0 = int(time.mktime(datetime.date.today().timetuple())) if now0 < vo.task_finish: return pass self.goTaskCenter() loge("滑动到看小说-点击") self.swipe_click(g_app_name, g_point_name_tap_kanxiaoshuo_task) self.sleep(5) loge("点击看小说书名") self.swipe_click(g_app_name, g_point_name_tap_kanxiaoshuo_task_book) loge("看小说") # 翻页一百次 for i in range(4): # 活去看小说权限 看一次广告 self.sleep(4) # 点击看小说中广告 self.swipe_click(g_app_name, g_point_name_tap_kanxiaoshuo_task_book_ad) loge("小说广告") self.toAd(36) self.swipe_h_times() pass loge("推出小说") self.back() loge("退出书架") self.back() loge("退出去赚钱页面") self.back() vo.task_finish = int(time.time()) self.getTaskDb().save(vo) pass