python使用atk框架自动化操作andrio手机滑屏

代码如下

#-*- encoding: utf-8 -*-
# Generated by recorder.
from time import sleep
from os import system
from subprocess import getoutput
import requests,pymysql,random
import atx
import random
#环境安装步骤如下
#python 版本号 3.70
# pip install --upgrade --pre uiautomator2
# python3 -m uiautomator2 init
# pip install -U weditor
# weditor --shortcut 创建
#金币比例 30000 比 1 软妹币
#撸羊毛代码。。。。。。。,今日头条阅读挂机。
#Source Code Witer By TonyShu
#今日头条极速版  邀请码:1055472046

def ReadBook(n,time_count):
    time_sleep = random.randint(5,10)
    dClick = random.randint(dW,dH)
#    d(className=u"android.widget.ImageView", resourceId=u"com.bytedance.novelplugin:id/novel_coin_exciting_ad_dismiss_btn").click(timeout=2200)
#    Kill 弹窗,躲避视频广告,不差这点金币
    d.swipe(800,dClick,100,dClick)
#    subprocess.Popen("adb shell input swipe {} {} {} {} {}".format(1000,1130,200,1130,step_), shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    print('正在使用今日头条读书--已点击{}下!本章看了{}秒!总共阅读{}分钟'.format(n,time_sleep,round(time_count/60,2)))
    sleep(time_sleep)
    return time_sleep


if __name__ == "__main__":
    d = atx.connect("5af3da78")
#开启调试模式
    d.debug = True
    dInfo=d.info
    dW = int(dInfo['displayWidth'])
    dH = int(dInfo['displayHeight'])
#    subprocess.Popen("adb connect ", shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    n = 1
    time_count = 1
    while 1:
        #生成随机整数,假装上翻下翻页
        rondom = random.randint(1,1)
        time_sleep = ReadBook(n,time_count)
        time_count += time_sleep     
        n += 1

运行效果如下:
在这里插入图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

shujitao

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值