AutoJS4.1.0实战教程 ---火火视频极速版签到、清理缓存和自动评论

火火视频邀请码:A6177939 看文章加关注点分享都不用...加下邀请码就好

推荐指数3颗星。稳定同时问题也被攻克所以推荐给大家。

自动评论、签到和清理缓存三合一代码分析给大家。

自动评论代码如下:

auto.waitFor();
let see_count = 1000;// rawInput('请输入滑动次数', '1000');
app.launchApp('火火视频极速版');
sleep(10000);
console.show(); //开启日志(悬浮窗权限)
try {
    let boundVideo = null;
    let bottomMenu = className("android.widget.RelativeLayout").find();
    console.show(); //开启日志(悬浮窗权限)
    for (let i = 0; i < bottomMenu.length; i++) {
        let video = bottomMenu[i].children().findOne(text("小视频"));
        if (video != null) {
            boundVideo = bottomMenu[i].bounds();
        }
    }
    click(boundVideo.centerX(), boundVideo.centerY());
    sleep(5000);
} catch (e) { }
var CommentKeyWord = [
    '我是火火视频极速版小助手关注了你你要关注我哦!',
    '山高路远坑深,大军纵横驰奔,谁敢横刀立马?惟有点赞加关注大军!',
    '我的未来不是梦我相信你也是',
    '身同感受',
];
console.show(); //开启日志(悬浮窗权限)
console.info("火火视频极速版");
huoHuoAutoComment();
home();//关闭当前程序

/**
 * 自动评论
 */
function huoHuoAutoComment(){
    let comment = CommentKeyWord[Math.floor(Math.random() * CommentKeyWord.length)];
    if(className("android.widget.TextView").text("评论").exists()){
        toastLog("开启自动评论");
        let b=className("android.widget.TextView").text("评论").findOnce().bounds();
        let clickResult= click(b.centerX(), b.centerY());
        if(clickResult){
            sleep(3000);
            setText(0,comment);
            sleep(3000);
            if (className("android.widget.TextView").text("发布").exists()) {
                if(className("android.widget.TextView").text("发布").findOnce().click()){
                    toastLog("自动评论成功");
                    back();
                }
            }
        }
    }
}

签到代码相对简单:

auto.waitFor();
app.launchApp('火火视频极速版');
sleep(8000);
console.show();

let bottomMenus = className("android.widget.RelativeLayout").find();
try {
    toastLog(bottomMenus.length);
    bottomMenus[bottomMenus.length - 1].click();
    sleep(3000);
    if (className("android.widget.TextView").text("首页").exists()) {
        toastLog("回到首页");
        let b= className("android.widget.TextView").text("首页").findOnce().bounds();
        click(b.centerX(),b.centerY());
    }
} catch (error) {
    console.error(error);
}

清理缓存,清理缓存代码不难,主要是返回的代码,回首页回不去了,写了点垃圾代码大家见笑了。

auto.waitFor();
app.launchApp('火火视频极速版');
sleep(10000);
let bottomMenus = className("android.widget.RelativeLayout").find();
try {
    bottomMenus[bottomMenus.length - 1].click();
    sleep(3000);
    clearMyCache();
} catch (error) {
    console.error(error);
}
//home();//关闭当前程序
/**
 * 清理缓存
 */
function clearMyCache() {
    if (className("android.widget.FrameLayout").id("q8").exists()) {
        toastLog("点击头像");
        let b = className("android.widget.FrameLayout").id("q8").findOnce().bounds();
        let clickResult = click(b.centerX(), b.centerY());
        sleep(3000);
        if (clickResult) {
            swipe(350, 1400, 350, 150, 300);
            sleep(5000);
            if (className("android.widget.TextView").text("设置").exists()) {
                toastLog("Click设置");
                let b = className("android.widget.TextView").text("设置").findOnce().bounds();
                click(b.centerX(), b.centerY());
            }
            sleep(3000);
            if (className("android.widget.TextView").text("清除缓存").exists()) {
                let b = className("android.widget.TextView").text("清除缓存").findOnce().bounds();
                click(b.centerX(), b.centerY());
            }
            sleep(3000);
            if (className("android.widget.Button").text("确定").exists()) {
                let b = className("android.widget.Button").text("确定").findOnce().bounds();
                let result=click(b.centerX(), b.centerY());
                if(result){
                    toastLog("清理成功");
                    back();
                    sleep(1000);
                    back();
                    back();
                    back();

                }else{
                    back();
                }
            }
        } else {
            toastLog("点击我的失败");
        }
    }
}
原创文章 89 获赞 55 访问量 4万+

猜你喜欢

转载自blog.csdn.net/zy0412326/article/details/105923541