AutoJs Pro 7.0.4-1 实战教程---史上最全快音短视频

邀请码:PG84CG ,推荐给大家比较稳定,就是不FHY!

1、自动滑动

2、自动签到

3、自动点赞

4、自动评论

5、曲线直线滑动区分

6、自动概率设定

7、滑动次数限制

8、时间间隔限制并随机4S

9、增加各类行日志如toastlError等

10、依据概率随机上滑

11、依据概率随机下滑

12、自动签到

13、自动提现

13、关闭广告和避开广告

auto.waitFor();

let appName = "快音"
let see_count = 1000;// rawInput('请输入滑动次数','1000');//手动输入滑动次数默认是1000次。
app.launchApp(appName);
console.show();
curveBrushScreen = false;//是否曲线滑动true取消滑动false直线滑动 v_close
probability=10;//概率自动点赞、评论、关注的概率
timesInterval = 8;//间隔时间
sleep(4000);
autoSign(appName);
clickVideoMenu();
for (var i = 1; i < see_count; i++) {
    toastLog(appName + "滑动" + i + "次" + "总计:" + see_count + "次");//系统自带目前我huweinova不显示还不知道为啥
    let x1 = random(device.width * 0.2, device.width * 0.3);
    let y1 = device.height * 0.8
    let x2 = random(device.width * 0.2, device.width * 0.3);
    let y2 = device.height * 0.1
    let pressTime = random(300, 500);

    closeAd();
     //福利页保障
    if (text("每日福利").exists()) {
        clickVideoMenu();
    }
    //我的页保障
    if (text("勋章中心").exists()) {
        clickVideoMenu();
    }

    randomHeart('video_like_parent', probability);//随机点赞
    kuaiYinRandomFollow(probability);
    randomUpSildeScreen(x1, y2, x1, y1, pressTime, probability);
    randomDownSildeScreen(x1, y1, x2, y2, pressTime, timesInterval, probability);
    slideScreenDown(x1, y1, x2, y2, pressTime, timesInterval, curveBrushScreen);
}
autoCashOut();
stopApp(appName);
home();


function clickVideoMenu(){
    if (className("android.widget.TextView").text("视频").exists()) {
        let b = className("android.widget.TextView").text("视频").findOnce().bounds();
        click(b.centerX(), b.centerY());
    }
}
function closeAd() {
    let x1 = random(device.width * 0.2, device.width * 0.3);
    let y1 = device.height * 0.8
    let x2 = random(device.width * 0.2, device.width * 0.3);
    let y2 = device.height * 0.1
    let pressTime = random(300, 500);
    if (id("v_close").exists()) {
        id("v_close").findOnce().click();
    }
    if (text("查看详情").exists()) {
        toastInfo("查看详情在边上滑动防止点击!");
        slideScreenDown(device.width * 0.2, y1, device.width * 0.2, y2, pressTime, timesInterval);
    }
    if (text("立即下载").exists()) {
        toastInfo("立即下载在边上滑动防止点击!");
        slideScreenDown(device.width * 0.2, y1, device.width * 0.2, y2, pressTime, timesInterval);
    }
    if (id("close").exists()) {
        toastInfo("close在边上滑动防止点击!");
        slideScreenDown(device.width * 0.2, y1, device.width * 0.2, y2, pressTime, timesInterval);
    }
}
function autoCashOut() {
    sleep(1000);
    if (text("福利").exists()) {
        let b = text("福利").findOnce().bounds();
        let clickResult = click(b.centerX(), b.centerY());
        if (clickResult) {
            sleep(1000);
            if (text("提现").exists()) {
                text("提现").findOnce().click();
                sleep(1000);
                clickResult = text("去提现").findOnce().click();
                if (clickResult) {
                    console.show();
                    toastLog("提现点击按钮成功");
                }
            }
        }
    }
}
function autoSign(appName) {
    if (text("福利").exists()) {
        let b = text("福利").findOnce().bounds();
        let clickResult = click(b.centerX(), b.centerY());
        if (clickResult) {
            sleep(10000);
            if (text("视频").exists()) {
                let video = className("android.widget.TextView").text("视频").findOnce();
                let b = video.bounds();
                click(b.centerX(), b.centerY());
            }
        }
        else {
            if (className("android.widget.TextView").text("视频").exists()) {
                console.info("快音点击,视频");
                let video = className("android.widget.TextView").text("视频").findOnce();
                let b = video.bounds();
                click(b.centerX(), b.centerY());
            }
        }
    }
}
function kuaiYinRandomFollow(probability) {
    index = random(1, parseInt(probability));
    if (index == 1) {
        if (text("关注").exists()) {
            text("关注").findOnce().click();
        }
    }
}
/**
 * 贝塞尔曲线
 * @param {坐标点} ScreenPoint 
 * @param {偏移量} Offset 
 */
function bezier_curves(ScreenPoint, Offset) {
    cx = 3.0 * (ScreenPoint[1].x - ScreenPoint[0].x);
    bx = 3.0 * (ScreenPoint[2].x - ScreenPoint[1].x) - cx;
    ax = ScreenPoint[3].x - ScreenPoint[0].x - cx - bx;
    cy = 3.0 * (ScreenPoint[1].y - ScreenPoint[0].y);
    by = 3.0 * (ScreenPoint[2].y - ScreenPoint[1].y) - cy;
    ay = ScreenPoint[3].y - ScreenPoint[0].y - cy - by;
    tSquared = Offset * Offset;
    tCubed = tSquared * Offset;
    result = {
        "x": 0,
        "y": 0
    };
    result.x = (ax * tCubed) + (bx * tSquared) + (cx * Offset) + ScreenPoint[0].x;
    result.y = (ay * tCubed) + (by * tSquared) + (cy * Offset) + ScreenPoint[0].y;
    return result;
}
/**
 * 滑动(默认概率是百分之三十)
 * @param {*} qx 
 * @param {*} qy 
 * @param {*} zx 
 * @param {*} zy 
 * @param {*} time 
 * @param {*} timesInterval 
 */
function slideScreenDown(qx, qy, zx, zy, time, timesInterval, CurveBrushScreen) {
    if (CurveBrushScreen) {
        curveDown(qx, qy, zx, zy, time, timesInterval); //曲线概率
    } else {
        lineDown(qx, qy, zx, zy, time, timesInterval); //直线概率
    }
}
/**
 * 概率0-9 大于3的时候采用曲线概率 小于3的时候直线概率
 */
function randomFunction() {
    return Math.floor(Math.random() * 10);
}
function curveDown(qx, qy, zx, zy, time, timesInterval) {
    toastInfo("曲线滑动");
    var xxy = [time];
    var point = [];
    var dx0 = {
        "x": qx,
        "y": qy
    };
    var dx1 = {
        "x": random(qx - 100, qx + 100),
        "y": random(qy, qy + 50)
    };
    var dx2 = {
        "x": random(zx - 100, zx + 100),
        "y": random(zy, zy + 50),
    };
    var dx3 = {
        "x": zx,
        "y": zy
    };
    for (var i = 0; i < 4; i++) {
        eval("point.push(dx" + i + ")");
    };
    for (let i = 0; i < 1; i += 0.08) {
        let newPoint = bezier_curves(point, i);
        xxyy = [parseInt(newPoint.x), parseInt(newPoint.y)]
        xxy.push(xxyy);
    }
    gesture.apply(null, xxy);

    let randomMin = timesInterval * 1000;
    let randomMax = (parseInt(timesInterval) + 2) * 1000;
    let delayTime = random(randomMin, randomMax);
    sleep(delayTime);
}
/**
 * 屏幕向下滑动并延迟8至12秒
 */
function lineDown(startX, startY, endX, endY, pressTime, timesInterval) {
    toastInfo("屏幕向下滑动");
    swipe(startX, startY, endX, endY, pressTime);
    let randomMin = timesInterval * 1000;
    let randomMax = (parseInt(timesInterval) + 2) * 1000;
    let delayTime = random(randomMin, randomMax);
    sleep(delayTime);
}
/**
 * 按照指定概率随机上滑
 * @param {*} startX 
 * @param {*} startY 
 * @param {*} endX 
 * @param {*} endY 
 * @param {*} pressTime 
 * @param {*} probability 
 */
function randomUpSildeScreen(startX, startY, endX, endY, pressTime, probability) {
    let randomIndex = random(1, parseInt(probability));
    if (randomIndex == 1) {
        swipe(startX, startY, endX, endY, pressTime);
        delayTime = random(12000, 15000);
        sleep(delayTime);
    }
}
/**
 * 连续下滑对上一个无兴趣
 * 其实得和上滑做个排他,既然无兴趣不要在上滑
 */
function randomDownSildeScreen(startX, startY, endX, endY, pressTime, timesInterval, probability) {
    let randomIndex = random(1, parseInt(probability));
    if (randomIndex == 1) {
        swipe(startX, startY, endX, endY, pressTime);
        sleep(2000);
        swipe(startX, startY, endX, endY, pressTime);
        sleep(timesInterval);
    }
}
/**
 * 输出Tosat和Info日志
 * @param {日志消息} messagge 
 */
function toastInfo(message) {
    toast(message)
    console.info(message)
}
/**
 * 输出Tosat和Error日志
 * @param {日志消息} messagge 
 */
function toastError(message) {
    toast(message)
    console.error(message)
}
function toastLog(message) {
    toast(message)
    console.log(message)
}
function toastWarn(message) {
    toast(message)
    console.warn(message)
}
/**
 * 按照指定概率随机上滑
 * @param {*} startX 
 * @param {*} startY 
 * @param {*} endX 
 * @param {*} endY 
 * @param {*} pressTime 
 * @param {*} probability 
 */
function randomUpSildeScreen(startX, startY, endX, endY, pressTime, probability) {
    let randomIndex = random(1, parseInt(probability));
    if (randomIndex == 1) {
        swipe(startX, startY, endX, endY, pressTime);
        delayTime = random(12000, 15000);
        sleep(delayTime);
    }
}
/**
 * 连续下滑对上一个无兴趣
 * 其实得和上滑做个排他,既然无兴趣不要在上滑
 */
function randomDownSildeScreen(startX, startY, endX, endY, pressTime, timesInterval, probability) {
    let randomIndex = random(1, parseInt(probability));
    if (randomIndex == 1) {
        swipe(startX, startY, endX, endY, pressTime);
        sleep(2000);
        swipe(startX, startY, endX, endY, pressTime);
        sleep(timesInterval);
    }
}
/**
 * 随机点赞
 * @param {点赞ID}} view_id 
 */
function randomHeart(view_id, probability) {
    index = random(1, parseInt(probability));
    if (index == 1) {
        var target = id(view_id).findOnce();
        if (target == null) {
            return;
        } else {
            target.click();
            sleep(1000);
        }
    }
}
/**
 * 随机关注
 * @param {控件ID} follow_view_id 
 * @param {概率} probability 
 */
function randomFollow(follow_view_id, probability) {
    index = random(1, parseInt(probability));
    if (index == 1) {
        var target = id(follow_view_id).findOnce();
        if (target == null) {
            return;
        } else {
            target.click();
            sleep(1000);
        }
    }
}
/**
 * 强制停止app
 * @param {应用名称} appName 
 */
function stopApp(appName) {
    try {
        openAppSetting(getPackageName(appName));
        sleep(3000);
        if (className("android.widget.Button").text("强行停止").exists()) {
            className("android.widget.Button").text("强行停止").findOnce().click();
        } else {
            if (text("强行停止").exists()) {
                text("强行停止").findOnce().click();
            }
        }
        sleep(3000);
        if (className("android.widget.Button").text("确定").exists()) {
            className("android.widget.Button").text("确定").findOnce().click();
            toastLog(appName + "已经停止!");
        }
        else {
            if (text("强行停止").exists()) {
                text("强行停止").findOnce().click();
                toastLog(appName + "已经停止!");
            } else {
                if (text("结束运行").exists()) {
                    text("结束运行").findOnce().click();
                    sleep(500);
                    if (text("确定").exists()) {
                        text("确定").findOnce().click();
                        toastLog("MIUI9 Android7"+appName + "已经停止!");
                    }
                }
            }
            
        }
    } catch (e) {
        toastLog(e);
    }
}

 

你可能感兴趣的:(AutoJs,薅羊毛,源代码)