autojs(短視頻腳本)


"ui";

ui.layout(
    <vertical>
    
        <appbar>
            <toolbar title="翻頁吧!"/>
        </appbar>

        <frame height="100" gravity="center">
            <text text="相關配置如下👇" gravity="center"/>
        </frame>
        
        <vertical>
            <button id="shuab" text="刷寶短視頻:開刷" />
            <button id="kuais" text="快手極速版:開刷" />
            <button id="jrtt" text="今日頭條:開刷" />
            <button id="douy" text="抖音極速版:開刷" />
        </vertical>

    </vertical>
);

// 事件綁定
ui.kuais.on("click", function(){
    runkais(1000);
});
ui.jrtt.on("click", function(){

    runjstt(1000);
});
ui.douy.on("click", function(){

    rundouyin(1000);
});
ui.shuab.on("click", function(){
    runShuaBao(1000);
});

auto.waitFor();
auto.setMode('normal');

// 啟動刷寶
function runShuaBao(set_count){
    threads.start(function() {
        console.show();
        launchApp("刷寶短視頻");
        sleep(2000);
        var width = device.width;
        var height = device.height;
        setScreenMetrics(width,height);
        waitForActivity("com.jm.video.ui.main.MainActivity");
        toastLog("開始刷視頻");
        sleep(1000);
        var current = 0,
            maxNum = set_count;//滑動次數


        function huaping(){
            
            //隨機等待時間random(最小值,最大值)根據需要更改數值(單位秒)
            var time_random=random(5,10);

            // 點擊
            try {
                click("首頁");    
            } catch (error) {
                console.log(error)
            }
            if (text("查看廣告").findOne(1000) != null){
                sleep(1000);
                back();
            }
            if(current > maxNum){
                toastLog("退出中...");
                exit();
                home();
            }

            //提示等待時間。
            toastLog(time_random+'秒后刷新'+','+'還有'+(maxNum-current)+'');
            sleep(time_random * 1000);
            current+=1;
        }

        // 開始循環上滑
        while(true){
            huaping();
        }
    })
}
//啟動快手
function runkais(set_count) {
    threads.start(function() {
        console.show();
        launchApp("快手極速版");
        sleep(3000);
        var width = device.width;
        var height = device.height;
        setScreenMetrics(width,height);
        while (true) {
            if (id("redFloat").findOne(1000) != null)
                break;
        }
        ks_sign();
        toastLog("開始刷視頻");
        sleep(1000);
        var timer = 0;
        var error_time = 0;
        var current = 0,
            maxNum = set_count;//滑動次數
        
        function huaping(){
            
            //隨機等待時間random(最小值,最大值)根據需要更改數值(單位秒)
            var time_random=random(5,10);

            timer += time_random;
            print("還剩" + (300 - timer) + "秒准備開箱");
            if(timer >= 300){
                open_box();
            }
            //滑動視頻
            swipe(width / 2, height * 3 / 4, width / 2, height / 10, 500);

            current+=1;
            if(current > maxNum){
                toastLog("退出中...");
                exit();
                home();
            }

            //提示等待時間。
            toastLog(time_random+'秒后刷新'+','+'還有'+(maxNum-current)+'');
            sleep(time_random * 1000);

        }
        //開寶箱
        function open_box() {
            if (id("redFloat").findOne(1000) != null){
            timer = 0;
            if (error_time > 10)  return;
                click(id("redFloat").findOne(1000).bounds().centerX(),id("redFloat").findOne(1000).bounds().centerY());
                sleep(random(1000,2000));
                if (text("開寶箱得金幣").findOne(1000) != null) {
                    text("開寶箱得金幣").findOne(1000).click();
                }else{
                    error_time ++;
                }
                sleep(random(1000,2000));
                if(text("看精彩視頻賺更多").findOne(1000) != null){
                    error_time = 0;
                    text("看精彩視頻賺更多").findOne(1000).parent().click();
                    sleep(45 * 1000);
                    back();
                    sleep(random(1000,2000));
                }
            }
            back();
            sleep(random(1000,2000));
        }
        //簽到
        function ks_sign() {
            if (id("redFloat").findOne(1000) != null){
                click(id("redFloat").findOne().bounds().centerX(),id("redFloat").findOne().bounds().centerY());
                toastLog("開始簽到");
                sleep(3000);
                if(text("立即簽到").findOne(1000) != null){
                    text("立即簽到").findOne().click();
                    if(text("今天已簽").findOne(1000) != null){
                        toastLog("簽到成功");
                    }else{
                        toastLog("簽到失敗");
                    }
                    sleep(random(1000,2000));
                    back();
                }else {
                    toastLog("今天好像簽到了");
                    sleep(random(1000,2000));
                    back();
                }

            }
        }
        while(true){
            huaping();
        }
    })
}
// 啟動抖音
function rundouyin(set_count){
    threads.start(function() {
        launchApp("抖音極速版");
        sleep(2000);
        var width = device.width;
        var height = device.height;
        setScreenMetrics(width,height);
        toastLog("開始刷視頻");
        sleep(1000);
        var current = 0,
            maxNum = set_count;//滑動次數


        function huaping(){
            
            //隨機等待時間random(最小值,最大值)根據需要更改數值(單位秒)
            var time_random=random(5,10);

            // 點擊
            try {
                click("首頁");    
            } catch (error) {
                console.log(error)
            }
            if(current > maxNum){
                toastLog("退出中...");
                exit();
                home();
            }

            //提示等待時間。
            toastLog(time_random+'秒后刷新'+','+'還有'+(maxNum-current)+'');
            sleep(time_random * 1000);
            current+=1;
        }

        // 開始循環上滑
        while(true){
            huaping();
        }
    })
}
//啟動今日頭條極速版
function runjstt(set_count){
    threads.start(function() {
        console.show();
        launchApp("今日頭條極速版");
        sleep(2000);
        var width = device.width;
        var height = device.height;
        setScreenMetrics(width,height);
        while(true){
            if(id("k2").findOne(1000) != null)  break;
        }
        toastLog("開始");
        sleep(1000);
        var timer = 0;
        var current = 0,
            maxNum = set_count;//滑動次數
        function huaping(){
            
            //隨機等待時間random(最小值,最大值)根據需要更改數值(單位秒)
            var time_random=random(5,10);
            timer += time_random;
            print("還剩" + (300 - timer) + "秒准備開箱");
            if(timer >= 300){
                open_box();
            }
            // 點擊
            try {
                click("首頁");    
            } catch (error) {
                console.log(error)
            }
            if(current > maxNum){
                toastLog("退出中...");
                exit();
                home();
            }

            //提示等待時間。
            toastLog(time_random+'秒后刷新'+','+'還有'+(maxNum-current)+'');
            sleep(time_random * 1000);
            current+=1;
        }
        function open_box() {
            click("任務")
            timer = 0;
            sleep(random(1000,2000));
            if(text("開寶箱得金幣").findOne(1000) != null){
                text("開寶箱得金幣").findOne(1000).parent().click();
                if(text("看完視頻再領").findOne(1000) != null){
                    text("看完視頻再領").findOne(1000).parent().click(); 
                    sleep(30 * 1000); 
                    back();
                    click("堅持退出")
                    print("視頻結束退出!")
                }
            }
            else 
                print("時間未到,返回首頁!")
            sleep(random(1000,2000));
            click("首頁");  

        }
        // 開始循環上滑
        while(true){
            huaping();
        }
    })
}

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM