Example #1
0
def schedule_apps(device, w, h):
    """
    做两次程序的定时任务
    第1次半个小时,其余时间用来看视频
    第2次做重要的任务
    """
    if datetime.now().minute < info.SCHEDULE_TIME:
        print('第1次定时任务 ' + datetime.now().time().__str__())
        for a in info.apps:
            try:
                getattr(schedule, a)(device, w, h)
            except NotImplementedError as e:
                print(a + ' schedule not implemented')
                continue

    if (datetime.now().hour % 4) == 1:
        # 手机休息180s
        phone.sleep_to_weak(device, w, h, gap=180)

    # [x] 看快手视频
    if datetime.now().minute < info.SCHEDULE_TIME:
        checkin.kuaishou(device)
        while datetime.now().minute < info.SCHEDULE_TIME:
            phone.swipe_down_to_up(device, w / 2, h, randrange(5, 16))
        phone.stop_app(device, info.packages['kuaishou'])

    print('第2次定时任务 ' + datetime.now().time().__str__())
    for a in info.apps:
        try:
            getattr(schedule, a)(device, w, h)
        except NotImplementedError as e:
            print(a + ' schedule not implemented')
            continue
Example #2
0
def cycle(device):
    # 需要手机保持亮屏状态
    # 获取手机像素大小
    (w, h) = phone.get_size(device)

    # 滑动手机打开屏幕
    phone.swipe_down_to_up(device, w / 2, h)

    phone.go_home(device)

    phone_packages = phone.list_packages(device)
    run_apps = []
    for p in info.packages:
        if phone_packages.__contains__(info.packages[p]):
            run_apps.append(p)
Example #3
0
def read_article(device, w, h, num):
    print('看文章' + str(num) + '次 ' + datetime.now().time().__str__())
    for i in range(0, num):
        # 获取文章目录
        phone.swipe_down_to_up(device, w / 2, h, internal=300)
        # 点击文章
        phone.tap(device, w / 2, h / 2)
        # 滑动阅读
        for j in range(0, 10):
            phone.swipe_down_to_up(device,
                                   w / 2,
                                   h,
                                   randrange(2, 5),
                                   internal=300)
        # 返回上级目录
        phone.go_back(device)
Example #4
0
def watch_douyin_video(device, w, h, hour):
    print('看抖音视频 ' + datetime.now().time().__str__())
    while datetime.now().hour == hour:
        phone.swipe_down_to_up(device, w / 2, h, randrange(5, 16))
Example #5
0
def watch_video(device, w, h, num):
    print('看视频' + str(num) + '次 ' + datetime.now().time().__str__())
    for i in range(0, num):
        phone.swipe_down_to_up(device, w / 2, h, randrange(5, 16))
Example #6
0
def run(device):
    # 获取手机的大小
    (w, h) = phone.get_size(device)
    # 滑动手机打开屏幕
    phone.swipe_down_to_up(device, w / 2, h)
    # 回到手机主页
    phone.go_home(device)

    # 代码测试位置
    schedule.test(device, w, h)

    while True:
        if datetime.now().hour != 0:
            utils.schedule_apps(device, w, h)

        while datetime.now().hour.__eq__(0):
            print('所有程序的签到工作 ' + datetime.now().time().__str__())
            for a in info.apps:
                if utils.is_coordinate_checkin(a):
                    try:
                        getattr(checkin, a)(device, w, h)
                    except NotImplementedError as e:
                        print(a + ' checkin not implemented')
                        continue
                else:
                    try:
                        getattr(checkin, a)(device)
                    except NotImplementedError as e:
                        print(a + ' checkin not implemented')
                        continue
                    # 所有程序的签到工作
                    try:
                        getattr(sign, a)(device, w, h)
                    except NotImplementedError as e:
                        print(a + ' sign not implemented')
                        continue
                    phone.stop_app(device, info.packages[a])

            utils.tail_work(device, w, h, 0)

        while datetime.now().hour == 1:
            utils.tail_work(device, w, h, hour=1)

        while datetime.now().hour == 2:
            utils.tail_work(device, w, h, hour=2)

        while datetime.now().hour == 3:
            utils.tail_work(device, w, h, hour=3)

        while datetime.now().hour == 4:
            utils.tail_work(device, w, h, hour=4)

        while datetime.now().hour == 5:
            utils.tail_work(device, w, h, hour=5)

        while datetime.now().hour == 6:
            utils.tail_work(device, w, h, hour=6)

        while datetime.now().hour == 7:
            utils.tail_work(device, w, h, hour=7)

        while datetime.now().hour == 8:
            utils.tail_work(device, w, h, hour=8)

        while datetime.now().hour == 9:
            utils.tail_work(device, w, h, hour=9)

        while datetime.now().hour == 10:
            utils.tail_work(device, w, h, hour=10)

        while datetime.now().hour == 11:
            utils.tail_work(device, w, h, hour=11)

        while datetime.now().hour == 12:
            utils.tail_work(device, w, h, hour=12)

        while datetime.now().hour == 13:
            utils.tail_work(device, w, h, hour=13)

        while datetime.now().hour == 14:
            utils.tail_work(device, w, h, hour=14)

        while datetime.now().hour == 15:
            utils.tail_work(device, w, h, hour=15)

        while datetime.now().hour == 16:
            utils.tail_work(device, w, h, hour=16)

        while datetime.now().hour == 17:
            utils.tail_work(device, w, h, hour=17)

        while datetime.now().hour == 18:
            utils.tail_work(device, w, h, hour=18)

        while datetime.now().hour == 19:
            utils.tail_work(device, w, h, hour=19)

        while datetime.now().hour == 20:
            utils.tail_work(device, w, h, hour=20)

        while datetime.now().hour == 21:
            utils.tail_work(device, w, h, hour=21)

        while datetime.now().hour == 22:
            utils.tail_work(device, w, h, hour=22)

        while datetime.now().hour == 23:
            utils.tail_work(device, w, h, hour=23)
Example #7
0
def single(device):
    (w, h) = phone.get_size(device)
    while True:
        phone.swipe_down_to_up(device, w / 2, h, randrange(5, 16))