AutoJS4.1.0实战教程 ---快手极速版签到

    我的快手极速版邀请码: 2rvxaem,看文章加关注点分享都不用...加下邀请码就好。再次友情提醒: 2rvxaem

签到每天给的金币还是非常不错的,所以实现自动签到是非常必要的。代码如下:

auto.waitFor();//判断和等待开启无障碍
app.launchApp('快手极速版');//只有一个快手极速版所以直接Launch就可以,不用包名
sleep(10000);//等待splash时间
console.show(); //开启日志(悬浮窗权限)
if (id("redFloat").exists()) {
    console.log("点击redFloat红包");
    let b = id("redFloat").findOne().bounds();
    click(b.centerX(), b.centerY());
    sleep(5000);
}
sleep(2000);
swipe(device.width / 2, device.height - 200, device.width / 2, 500, 700);
sleep(2000);
if (className("android.widget.Button").text("去签到").exists()) {
    console.log("快手极速版去签到");
    let b = text("去签到").findOne().bounds();
    click(b.centerX(), b.centerY());
    //TODO 关闭按钮也是无ID 无desc的×
    back();
}
stopApp('快手极速版');//停止APP(Android7和Android10亲测)
/**
 * 强制停止app
 * @param {应用名称} appName 
 */
function stopApp(appName){
    openAppSetting(getPackageName(appName));
    console.show();
    sleep(3000);
    if (className("android.widget.Button").text("强行停止").exists()) {
        console.info("强行停止");
    }
    className("android.widget.Button").text("强行停止").findOnce().click();
    try {
        sleep(3000);
        if (className("android.widget.Button").text("确定").exists()) {
            className("android.widget.Button").text("确定").findOnce().click();
            toastLog(appName + "已经停止!");
        }
        else {
            let closeButton = className("android.widget.Button").text("强行停止").find();
            console.info(closeButton.length);
            console.info(closeButton[0].bounds());
            closeButton[0].click();
            toastLog(appName + "已经停止!");
        }
    } catch (e) {
        toastLog(e);
    }
}

强制关闭程序得代码也有了。接下来搞一波看直播的代码。

下图是我的成果大家加油啊~~~

30多天的成果大
发布了46 篇原创文章 · 获赞 12 · 访问量 1万+

猜你喜欢

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