手机版 欢迎访问it开发者社区(www.mfbz.cn)网站

当前位置: > 开发

AutoJsPro,阿伟的假期(看广告游戏)脚本实例

时间:2021/9/20 19:51:34|来源:|点击: 次

本文章实例内容:
ui界面
Q群/QQ跳转添加
控件检测&点击
识图点击
线程运用
前台判断(包名检测)
话不多说
无暗桩
脚本自提
造雾者/收徒/定制/版权/项目投稿
造雾者QQ:1340468168
脚本/注册机/协议 投稿&拜师联系我

"ui";
ui.statusBarColor("#000000")
var author = "1340468168"; //作者QQ
var projectGroup = "740578431"; //项目群
var communicationGroup = "909116228"; //交流群
app.startActivity({
    action: "android.intent.action.VIEW",
    data: "mqqapi://card/show_pslcard?card_type=group&uin=" + projectGroup,
    packageName: "com.tencent.mobileqq",
}); //强制引流
ui.layout(
    <drawer id="drawer">
        <vertical>
            <toolbar id="toolbar" w="*" h="auto" bg="#FFFFFF" >
                <horizontal w="*">
                    <img id="author" w="40" h="40" scaleType="fitXY" circle="true" layout_gravity="left" src="https://pic.imgdb.cn/item/60a383c26ae4f77d3597a322.jpg" />
                    <text w="*" text="造雾者—阿伟的假期1.0" textColor="#000000" gravity="center" textSize="20sp" textStyle="bold" />
                </horizontal>
            </toolbar>
            
            <horizontal>
                <TextView id="tvText" singleLine="true" ellipsize="marquee" focusable="true" textColor="black" textSize="16sp" textStyle="bold" text="本脚本作者为@造雾者,此软件仅用于学习和交流,如果使用过程中发生一切违规行为,作者概不负责!" />
            </horizontal>
            <card w="*" h="40" cardBackgroundColor="#000000" margin="1 1 1 1" cardElevation="1dp" gravity="center_vertical" alpha="1" cardCornerRadius="3dp">
                <card w="*" h="36" cardCornerRadius="2dp" margin="2" cardElevation="1dp" gravity="center_vertical" alpha="1" cardCornerRadius="1">
                    <linear orientation="horizontal">
                        <Switch w="150" id="accessibilityPermissions" text="无障碍服务" textColor="black" textStyle="bold" checked="{{auto.service != null}}" padding="8 8 8 8" textSize="15sp" />
                        <text textSize="11sp" layout_weight="1" text="点击开关打开或关闭无障碍" textColor="black" gravity="center" w="18" singleLine="true" />
                    </linear>
                </card>
            </card>
            
            <card w="*" h="40" cardBackgroundColor="#000000" margin="1 1 1 1" cardElevation="1dp" gravity="center_vertical" alpha="1" cardCornerRadius="3dp">
                <card w="*" h="36" cardCornerRadius="2dp" margin="2" cardElevation="1dp" gravity="center_vertical" alpha="1" cardCornerRadius="1">
                    <linear orientation="horizontal">
                        <Switch w="150" id="xfc" text="悬浮窗权限" textColor="black" textStyle="bold" padding="8 8 8 8" textSize="15sp" />
                        <text textSize="11sp" layout_weight="1" text="点击开关打开或关闭悬浮窗" textColor="black" gravity="center" w="18" singleLine="true" />
                    </linear>
                </card>
            </card>
            
            <card w="*" h="40" cardBackgroundColor="#000000" margin="1 1 1 1" cardElevation="1dp" gravity="center_vertical" alpha="1" cardCornerRadius="3dp">
                <card w="*" h="36" cardCornerRadius="2dp" margin="2" cardElevation="1dp" gravity="center_vertical" alpha="1" cardCornerRadius="1">
                    <text text="开始运行" textStyle="bold" id="start" gravity="center" w="1080px" margin="0 0 0 0" textColor="#000000" textSize="15sp" />
                </card>
            </card>
            
            <card w="*" h="40" cardBackgroundColor="#000000" margin="1 1 1 1" cardElevation="1dp" layout_gravity="left" alpha="1" cardCornerRadius="3dp">
                <card w="*" h="36" cardCornerRadius="2dp" margin="2" cardElevation="1dp" gravity="center_vertical" alpha="1" cardCornerRadius="1">
                    <text text="加入QQ项目群" textStyle="bold" id="joinGroup" gravity="center" w="1080px" margin="0 0 0 0" textColor="#000000" textSize="15sp" />
                </card>
            </card>
            
            <card w="*" h="40" cardBackgroundColor="#000000" margin="1 1 1 1" cardElevation="1dp" gravity="center_vertical" alpha="1" cardCornerRadius="3dp">
                <card w="*" h="36"  cardCornerRadius="2dp" margin="2" cardElevation="1dp" gravity="center_vertical" alpha="1" cardCornerRadius="1">
                    <text text="点击下载软件" textStyle="bold" id="xz" gravity="center" w="1080px" margin="0 0 0 0" textColor="#000000" textSize="15sp" />
                </card>
            </card>
            
            <card w="*" h="60" cardBackgroundColor="#000000" margin="1 1 1 1" cardElevation="1dp" gravity="center_vertical" alpha="1" cardCornerRadius="3dp">
                <card w="*" h="56"  cardCornerRadius="2dp" margin="2" cardElevation="1dp" gravity="center_vertical" alpha="1" cardCornerRadius="1">
                    <horizontal>
                        <text text="识别度:" textColor="#212121" marginLeft="7" w="auto" marginTop="9" textSize="18sp" />
                        <seekbar marginLeft="-15" w="180" id="识别" progress="-10" max="9" marginTop="11" textSize="18sp" />
                        <text id="sb" text="1" textColor="#FFFF0000" w="35" marginTop="9" textSize="18sp" />
                        <text text="率" textColor="#212121" w="30" marginTop="9" textSize="18sp" />
                    </horizontal>
                    <text  text="text" singleLine="true" ellipsize="marquee" focusable="true" textColor="#FFD700" textSize="14sp"     paddingTop="34"       textStyle="bold" text="全适配分辨率  默认0.8" />
                </card>
            </card>
            
            
            <frame height="500" gravity="center">
                <vertical>
                    <card w="*" h="0" cardBackgroundColor="#000000" margin="1 1 1 1" cardElevation="1dp" gravity="center_vertical" alpha="1" cardCornerRadius="3dp">
                        <card w="*" h="1" cardCornerRadius="2dp" margin="2" cardElevation="1dp" gravity="center_vertical" alpha="1" cardCornerRadius="1" />
                    </card>
                    <card w="*" h="350" cardBackgroundColor="#000000" margin="1 1 1 1" cardElevation="1dp" gravity="center_vertical" alpha="1" cardCornerRadius="3dp">
                        <card w="*" h="395" cardCornerRadius="2dp" margin="2" cardElevation="1dp" gravity="center_vertical" alpha="1" cardCornerRadius="1">
                            <vertical>
                                <text text="项目公告" textStyle="bold" gravity="center" w="1080px" margin="0 10 0 0" textSize="15sp" />
                                <text text="加入q群,联系作者反馈bug🏆🏆" textStyle="bold" gravity="center" w="1080px" margin="0 10 0 0" textSize="15sp" />
                                <text text="加入QQ项目群,每天更新项目哦~~~" textStyle="bold" gravity="center" w="1080px" margin="0 10 0 0" textSize="15sp" />
                                <text text="运行的时候没有点击的话,改一下分辨率试试!" textStyle="bold" gravity="center" w="1080px" margin="0 10 0 0" textSize="15sp" />
                                <text text="项目挺暴力的,一次广告0.2元,放心用脚本挂" textStyle="bold" gravity="center" w="1080px" margin="0 10 0 0" textSize="15sp" />
                                <text text="年轻是我们唯一拥有权利去编织梦想的时光。" textStyle="bold" gravity="center" w="1080px"  paddingTop="120"   textSize="15sp" />
                                <text text="                                            ——造雾者" textStyle="bold" gravity="center" w="1080px" margin="0 10 0 0" textSize="15sp" />
                                
                                
                                
                            </vertical>
                        </card>
                    </card>
                    <card w="*" h="30" cardBackgroundColor="#000000" margin="1 1 1 1" cardElevation="1dp" gravity="center_vertical" alpha="1" cardCornerRadius="3dp">
                        <card w="*" h="26" cardCornerRadius="2dp" margin="2" cardElevation="1dp" gravity="center_vertical" alpha="1" cardCornerRadius="1">
                            <text text="作者--@造雾者." gravity="center" />
                        </card>
                    </card>
                </vertical>
            </frame>
        </vertical>
    </drawer>
);

ui.tvText.setSelected(true); //滚屏公告
//======================================

ui.author.on("click", function() {
    app.startActivity({
        action: "android.intent.action.VIEW",
        data: "mqqapi://card/show_pslcard?uin=" + author,
        packageName: "com.tencent.mobileqq",
    });
}); //左上角联系作者图标事件
//=======================================

ui.joinGroup.on("click", function() {
    app.startActivity({
        action: "android.intent.action.VIEW",
        data: "mqqapi://card/show_pslcard?card_type=group&uin=" + projectGroup,
        packageName: "com.tencent.mobileqq",
    }); //强制引流
}); //加入群聊点击事件
//========================================

ui.emitter.on("create_options_menu", menu => {
    menu.add("");
});
//=============================================

ui.xfc.click(function() {
    floaty.requestPermission();
})

//===============================================

ui.emitter.on("resume", function() {
    // 此时根据无障碍服务的开启情况,同步开关的状态
    ui.xfc.checked = floaty.checkPermission()
});
//===================================================

ui.xfc.checked = floaty.checkPermission()


activity.setSupportActionBar(ui.toolbar);
//======================================================

ui.accessibilityPermissions.on("check", function(checked) {
    toastLog("请打开无障碍权限")
    if (checked && auto.service == null) {
        app.startActivity({
            action: "android.settings.ACCESSIBILITY_SETTINGS"
        });
    };
    if (!checked && auto.service != null) {
        auto.service.disableSelf();
    };
}); //无障碍权限检测与跳转
//==========================================================

ui.emitter.on("resume", function() {
    ui.accessibilityPermissions.checked = auto.service != null;
}); // 无障碍开关状态检测
//===========================================================
ui.xz.on("click", () => {
    app.openUrl("http://sdtaisheng.cn/index.html?uid=101003785&from=0")
}) //APP下载
//===========================================================


storage = storages.create("awtlq")
识别率 = storage.get("识别率", 0.8)
ui.sb.setText(String(识别率))
ui.识别.progress = 识别度返回(识别率)
ui.识别.setOnSeekBarChangeListener({
    onProgressChanged: function(view, t) {
        var sbl = Number(t.toString())
        识别率 = 识别度(sbl)
        storage.put("分辨率", 识别率);
    }
})






ui.start.on("click", function() {
    if (auto.service == null) {
        toast("请先开启无障碍服务!");
        return;
    };
    threads.start(造雾者);
}); //程序开始运行之前判断无障碍服务



function 造雾者() {



    threads.start(function() {


        //请求截图,用找图方法,第一个就要先写的请求截图代码,不然找图没法用
        if (!requestScreenCapture()) {
            toast("请求截图失败");
            exit();
        }



 var w;
    var runTime = (function() {
        var startTime = new Date().getTime();
        return function() {
            //账号(账号计数);
            var endTime = new Date().getTime();
            var spendTime = Math.floor((endTime - startTime) / 1000);
            let mok = util.format('%d', spendTime);
            return (
                parseInt(mok / 60 / 60) +
                '时 ' +
                (parseInt(mok / 60) % 60) +
                '分 ' +
                (mok % 60) +
                '秒,----阿伟的假期' +
                '  当前电量:' +
                device.getBattery() +
                '% @造雾者'

            );
        };
    })();

    threads.start(function() {
        cumtomUI();
        setInterval(function() {
            let mok = runTime();
            if (mok) {
                try {
                    if (mok) ui.run(() => w.时间.text(mok));
                } catch (error) {}
            }
        }, 1000);
    });

    function cumtomUI() {
        let resource = context.getResources();
        w = floaty.rawWindow(
            <relative>
                <frame bg="#44ffcc00" w="*" h="{{device.height / 4}}">
                    <vertical w="*">
                        <card
                        id="indx2"
                        w="*"
                        margin="0 0 0 1"
                        h="auto"
                        background="#000000"
                        cardCornerRadius="3"
                        cardElevation="2dp"
                        gravity="left"
                        >
                        <horizontal gravity="left" w="*">
                            <text
                            w="auto"
                            h="auto"
                            textSize="10"
                            margin="8 0 0 0"
                            textColor="#ffffff"
                            >
                            已运行:
                        </text>
                        <text
                        w="auto"
                        h="auto"
                        textSize="10"
                        margin="8 0 20 0"
                        id="时间"
                        textColor="#00ffd8"
                        text="0时 0分 0秒"
                        />
                    </horizontal>
                </card>
                <View w="*" h="2px" bg="#c0c0c0" />
                <com.stardust.autojs.core.console.ConsoleView
                id="console"
                background="#7f000000"
                h="*"
                />
            </vertical>
            </frame>
            </relative>
        );
        w.setTouchable(false);
        w.setPosition(0, device.height - device.height / 5 - 0); //设置悬浮窗位置
        w.setSize(device.width, device.height / 9 + 100); //设置悬浮窗大小
        w.console.setConsole(runtime.console);
        let c = new android.util.SparseArray();
        let Log = android.util.Log;
        c.put(
            Log.VERBOSE,
            new java.lang.Integer(colors.parseColor('#dfc0c0c0'))
        );
        c.put(Log.DEBUG, new java.lang.Integer(colors.parseColor('#ffffffff')));
        c.put(Log.INFO, new java.lang.Integer(colors.parseColor('#ff64dd17')));
        c.put(Log.WARN, new java.lang.Integer(colors.parseColor('#ff2962ff')));
        c.put(Log.ERROR, new java.lang.Integer(colors.parseColor('#ffd50000')));
        c.put(
            Log.ASSERT,
            new java.lang.Integer(colors.parseColor('#ffff534e'))
        );
        // w.console.setColors(c);
        try {
            ui.run(function() {
                input_container = w.console.findViewById(
                    getResourceID('input_container', 'id')
                );
                input_container.attr('visibility', 'gone');
            });

        } catch (error) {}

        function getResourceID(name, defType) {
            return resource.getIdentifier(
                name,
                defType,
                context.getPackageName()
            );
        }
        setInterval(() => {}, 1000);
    }
    /**
     * 自定义打印函数
     * @param {文本} txt  需要打印的文本内容
     * @param {颜色} paatern 需要打印的颜色 l==黑色,v=黑色,i=绿色,e=红色
     */
    function putlog(txt, paatern, bul) {
        let type = paatern || 'v'; //未传入打印类型时,默认打印灰色
        let tybe = bul || false;
        let colBox = {
            l: 'log',
            '': 'verbose',
            i: 'info',
            e: 'error'
        };
        console[colBox[type]]('  ' + txt);
    }





    /* for (;;) {
         //console.color("你好")
        // console.color("12345612")
         // console.verbose("这个调试信息是灰色的");
         // console.info("autojs的日志变绿色了");
         //  console.warn("蓝色的调试信息");
         // console.error("红色的调试信息");
         sleep(1000)
     }*/







        auto.waitFor()
        console.info("正在打开阿伟的假期")
        launchApp("阿伟的假期")

        toastLog("8秒后运行脚本")
        //  toastLog("如果想运行抽奖功能请进入手动抽奖界面,默认执行自动种植")


        sleep(8000)






        while (true) {


            找图方法2("收获", 识别率, 1, 1)
            找图方法2("气泡红包", 识别率, 1, 1)
            找图方法2("开", 识别率, 1, 1)
            找图方法2("开心收下", 识别率, 1, 1)
            找图方法2("施肥", 识别率, 1, 1)
            找图方法2("浇水", 识别率, 1, 1)
            找图方法2("红关", 识别率, 1, 1)
        //    找图方法2("气泡红包", 识别率, 1, 1)
        //    找图方法2("开", 识别率, 1, 1)
       //     找图方法2("开2", 识别率, 1, 1)
       //     找图方法2("开心收下", 识别率, 1, 1)
       //     找图方法2("开2", 识别率, 1, 1)
      //      找图方法2("开3", 识别率, 1, 1)
       //     找图方法2("开4", 识别率, 1, 1)
        //    找图方法2("红包1", 识别率, 1, 1)
        //    找图方法2("红包2", 识别率, 1, 1)
       //     找图方法2("恭喜获得", 识别率, 1, 1)

            /*找图方法2("收取", 识别率, 1, 1)
            找图方法2("加倍", 识别率, 10, 10)
            找图方法2("抽奖", 识别率, 1, 1)
            /*
            if (找图方法2("生产奖励", 识别率, 1, 1)) {
                找图方法2("平台关闭", 识别率, 1, 1)
            } else {
                //log("完美运行")
            }

*/

            /关闭通杀
            找图方法3("关闭1", 识别率, 2, 2)
            找图方法3("关闭2", 识别率, 2, 2)
            找图方法3("关闭3", 识别率, 2, 2)
            找图方法3("关闭4", 识别率, 2, 2)
            找图方法3("关闭5", 识别率, 2, 2)
            //  找图方法3("关闭6", 识别率, 2, 2)



        }
    })




    threads.start(function() {
        while (true) {
            关闭广告()

            控件判断1("推荐", 0, 0)
            控件判断2()


        }


    })

    threads.start(function() {
        while (true) {


            控件点击(text, "禁止", "禁止")
            控件点击(text, "确定", "确定")
            控件点击(text, "点击领取", "点击领取")
            控件点击(text, "点击领取", "点击领取")
            控件点击(text, "点击领取", "点击领取")
      //      控件点击(text, "领红包", "领红包")
            控件点击(text, "领红包", "领红包")
      //      控件点击(text, "看视频拆红包", "看视频拆红包")
            //  控件点击(text, "取消", "取消")
     //       控件点击(text, "看视频拆红包", "看视频拆红包")
            控件点击(text, "看视频拆红包", "看视频拆红包")
            控件点击(text, "放弃下载", "放弃下载")
            控件点击(text, "无法关闭", "无法关闭")
            控件点击(text, "3元领跑新学期>", "点击然后退出")
            控件点击(text, " 一键参团", "提高活跃")
            控件点击(text, " 适合3~4周岁孩子", "提高活跃")
        }
    })



    function 找图方法2(所找图, 识别率, a, b) {

        let 大图 = captureScreen()
        let 小图1 = images.read("阿伟的假期/" + 所找图 + ".jpg");
        let 缩放x = device.width / 720
        let 缩放y = device.height / 1600
        let 小图 = images.scale(小图1, 缩放x, 缩放y)
        let result = images.matchTemplate(大图, 小图, {
            max: 5,
            region: [0, 0, device.width, device.height], //区域
            threshold: 识别率,
        });

        if (result != null) {
            for (let i = 0; i < result.matches.length; i++) {
                let pp = result.matches[i].point
                // log(pp)
                // console.nk
                console.warn("找到" + 所找图, pp.x, pp.y)

                click(pp.x + a, pp.y + b)
                //  log(pp.x, pp.y)
                console.error("点击--" + 所找图)
                sleep(200)
                break;
            }
        } else {
            console.log("===未找到" + 所找图)
        }
    }


}




function 找图方法3(所找图, 识别率, a, b) {

    let 大图 = captureScreen()
    let 小图1 = images.read("关闭通杀/" + 所找图 + ".png");
    let 缩放x = device.width / 1080
    let 缩放y = device.height / 2400
    let 小图 = images.scale(小图1, 缩放x, 缩放y)
    let result = images.matchTemplate(大图, 小图, {
        max: 5,
        region: [0, 0, device.width, device.height], //区域
        threshold: 识别率,
    });

    if (result != null) {
        for (let i = 0; i < result.matches.length; i++) {
            let pp = result.matches[i].point
            // log(pp)
            // console.nk
            console.warn("找到" + 所找图, pp.x, pp.y)

            click(pp.x + a, pp.y + b)
            //  log(pp.x, pp.y)
            console.error("点击--" + 所找图)
            sleep(200)
            break;
        }
    } else {
        console.log("===未找到" + 所找图)
    }
}





function 关闭广告() {
    /*
        //若无id就用classesname
        let 弹窗广告 = className("android.view.View").depth("9").indexInParent("2").findOnce();
        if (弹窗广告) {
            press(弹窗广告.bounds().centerX(), 弹窗广告.bounds().centerY(), 1)
            console.log("关闭弹窗")
            sleep(1000)
        }

        let 衣服广告 = className("android.widget.ImageView").drawingOrder("2").indexInParent("1").findOnce();
        if (衣服广告) {
            press(衣服广告.bounds().centerX(), 衣服广告.bounds().centerY(), 1)
            console.log("关闭广告")
            sleep(1000)
        }
        let 广告1 = className("android.widget.ImageView").depth("6").indexInParent("1").findOnce();
        if (广告1) {
            press(广告1.bounds().centerX(), 广告1.bounds().centerY(), 1)
            console.log("广告1")
            sleep(1000)
        }

    */
    let 弹窗广告2 = className("android.widget.ImageView").depth("4").indexInParent("1").findOnce();
    if (弹窗广告2) {
        press(弹窗广告2.bounds().centerX(), 弹窗广告2.bounds().centerY(), 1)
        console.log("关闭弹窗2")
        sleep(1000)
    }
    let 广告2 = className("android.widget.ImageView").depth("5").drawingOrder("5").indexInParent("1").findOnce();
    if (广告2) {
        press(广告2.bounds().centerX(), 广告2.bounds().centerY(), 1)
        console.log("关闭广告2")
        sleep(1000)
    }

    if (id("close_imageview").findOnce()) {
        id("close_imageview").findOnce().click();
        console.info("--关闭广告")
        //a = 1;toast("已看"+a+"次广告1");a++;
        sleep(500)
    }
    //下面是广告完在线咨询
    if (id("multiline-consult").findOnce()) {
        id("multiline-consult").findOnce().click();
        console.info("点击在线咨询")
        //a = 1;toast("已看"+a+"次广告1");a++;
        sleep(500)
    }


    if (id("tt_titlebar_close").findOnce()) {
        id("tt_titlebar_close").findOnce().click();
        console.info("--关闭广告")
        //a = 1;toast("已看"+a+"次广告1");a++;
        sleep(500)
    }
    //下面是返回
    if (id("detail_back").findOnce()) {
        id("detail_back").findOnce().click();
        console.info("--返回")
        //a = 1;toast("已看"+a+"次广告1");a++;
        sleep(500)
    }



    if (id("close").findOnce()) {
        id("close").findOnce().click();
        console.info("--关闭广告")
        //a = 1;toast("已看"+a+"次广告1");a++;
        sleep(500)
    }

    //   if (id("tt_splash_skip_btn").findOnce()) {
    //     id("tt_splash_skip_btn").findOnce().click();
    //       console.info("--跳过广告")
    //a = 1;toast("已看"+a+"次广告1");a++;
    //       sleep(500)
    //    }

    if (id("tt_insert_dislike_icon_img").findOnce()) {
        id("tt_insert_dislike_icon_img").findOnce().click();
        console.info("--关闭弹窗")

        //a = 1;toast("已看"+a+"次广告1");a++;
        sleep(500)
    }

    if (id("ksad_end_close_btn").findOnce()) {
        id("ksad_end_close_btn").findOnce().click();
        console.info("--关闭广告1")
        // a = 1;toast("已看"+a+"次广告1");a++;
        sleep(500)
    }

    if (id("tt_video_ad_close_layout").findOnce()) {
        id("tt_video_ad_close_layout").findOnce().click();
        console.info("--关闭广告2")
        //i = 1;toast("已看"+i+"次广告2");i++;
        sleep(500)
    }


    if (id(" reward_ad_close").findOnce()) {
        id(" reward_ad_close").findOnce().click();
        console.info("--关闭广告3")
        //i = 1;toast("已看"+i+"次广告2");i++;
        sleep(500)
    }


}

function 控件判断1(ttext, kong, clas) {
    var texi = null;
    var 是否可点 = false;
    var 是否找到 = false;
    //  console.log("[控件判断]", "进入类库:ttext=" + ttext + "&kong=" + kong + "&clas=" + clas);
    if (kong == 0) {
        texi = className(clas).text(ttext).findOne(1000);
        if (texi) 是否找到 = true;
        if (是否找到 == false) {
            //console.info("不在app界面,重新进入app")
            //launchApp("体重保卫战")
            //  console.log("[控件判断]", "是否找到:" + 是否找到);
            texi = className(clas).textContains(ttext).findOne(1000);
        } else {
            console.info("不在app界面,重新进入app")
            launchApp("阿伟的假期")
            // console.log("[控件判断]", "是否找到:" + 是否找到);
        }
    } else if (kong == 1) {
        texi = className(clas).textContains(ttext).findOne(1000);
    } else if (kong == 2) {
        var fsfan = className(clas).textContains(ttext).find();
        var lengt = fsfan.length - 1;
        //console.log("[控件判断]", "lengt=" + lengt);
        texi = fsfan[lengt];
    } else if (kong == 3) {
        texi = className("Button").textContains(ttext).findOne(1000);
    }
    if (是否找到 == false) {
        if (texi) {
            是否找到 = true;
        }
    }
    // console.log("[控件判断]", "完毕:" + 是否找到);
    return texi;
}


function  控件点击(dshuxing,  dzhi,  dname)  {

    var  a  =  dshuxing(dzhi).boundsInside(0,  0,  device.width,  device.height).findOnce();

    if  (a  !=  null)  {

        var  x1  =  a.bounds().left;

        var  x2  =  a.bounds().right;

        var  y1  =  a.bounds().top;

        var  y2  =  a.bounds().bottom;

        var  x  =  random(Math.floor(x1  +  1),  Math.floor(x2  -  1)); //删除控件四周1的边界,防止边框位置点击无效

        var  y  =  random(Math.floor(y1  +  1),  Math.floor(y2  -  1));

        var  timedelay  =  random(50,  150);

        log("点击 ["  +  dname  +  "]");

        press(x,  y,  timedelay);

        sleep(1000);

        return  true;

    } 
    else  {

        //toastLog("无法找到 ["  +  dname  +  "]");

        //其他内容

    }
}


function 控件判断2() {

    var name = getPackageName("阿伟的假期"); //返回"com.tencent.mobileqq"
    if (currentActivity() != getPackageName("阿伟的假期")) {

        app.launch(getPackageName("阿伟的假期"))

    }
}





function 识别度(sbl) {
    switch (sbl) {
        case 0:
            ui.sb.setText("0.5") //这个是数字显示
            return 0.5
        case 1:
            ui.sb.setText("0.55") //这个是数字显示
            return 0.55
        case 2:
            ui.sb.setText("0.6") //这个是数字显示
            return 0.6
        case 3:
            ui.sb.setText("0.65") //这个是数字显示
            return 0.65
        case 4:
            ui.sb.setText("0.7") //这个是数字显示
            return 0.7
        case 5:
            ui.sb.setText("0.75") //这个是数字显示
            return 0.75
        case 6:
            ui.sb.setText("0.8") //这个是数字显示
            return 0.8
        case 7:
            ui.sb.setText("0.85") //这个是数字显示
            return 0.85
        case 8:
            ui.sb.setText("9") //这个是数字显示
            return 9
        case 9:
            ui.sb.setText("0.95") //这个是数字显示
            return 0.95
        case 10:
            ui.sb.setText("1") //这个是数字显示
            return 1
        default:
            return 0.6
    }
}

function 识别度返回(sbl) {
    log(sbl)
    switch (sbl) {
        case 0.5:
            return 0
        case 0.55:
            return 1
        case 0.6:
            return 2
        case 0.65:
            return 3
        case 0.7:
            return 4
        case 0.75:
            return 5
        case 0.8:
            return 6
        case 0.85:
            return 7
        case 0.9:
            return 8
        case 0.95:
            return 9
        case 1:
            return 10
        default:
            return 2
    }
}

Copyright © 2002-2019 某某自媒体运营 版权所有