蚂蚁森林自动收能量

auto.waitFor();

threads.start(function () { images.requestScreenCapture(); });
while (!click("立即开始")) { };

app.launchApp("支付宝");
sleep(1500);
click("蚂蚁森林");
sleep(1500);

function collect() {
    log(1111111111111111111);
    let point = depth(15).textStartsWith("收集能量").find();
    point.forEach(child => {
        log(child);
        let Rect = child.bounds();
        click(Rect.centerX(), Rect.centerY());
        sleep(1000);
    });
    log(2222222222222);
}
collect();
sleep(1000);
if(text("查看更多好友").exists()) {
    click("查看更多好友");
    sleep(1500);
}

// 29 160 110 1DA06E
let f = depth(9).className("com.uc.webview.export.WebView").findOne();
let cnt = 0;
while(true) {
    if (cnt == 2) break;
    let t = f.child(0).child(0).child(0).child(0).child(1);
    let agg = t.children().find(visibleToUser(true).depth(15)); //只能找第一层的子控件,并返回集合
    let img = images.captureScreen();

    agg.forEach(child => {
        let point = child.child(4).bounds();
        // log(point);
        vis = images.findColorEquals(img, "#1DA06E", point.left, point.top, 69, 69);
        // images.pixel(image, x, y) colors.equals(color1, color2)
        vis2 = colors.equals("#FFFFFF", images.pixel(img, point.left+49, point.top+45));
        // vis2 = images.findColorEquals(img, "#FFFFFF", point.left, point.top, 49, 45);
        if (vis && vis2){
            log("找到了");
            click(child.bounds().centerX(), child.bounds().centerY());
            sleep(2000);
            collect();
            sleep(1000);
            back();
            sleep(1500);
        }
    });

    scrollable(true).find().scrollForward();
    
    //if (visibleToUser(true).depth(15).text("没有更多了").exists()) cnt++;
    let clip = images.read('/sdcard/mysl.jpg');
    var p = findImage(img, clip);
    if (p) cnt++;
    if (p) sleep(500);
    else sleep(1500);
}

// log(cnt);

toast("end");

  

posted @ 2020-09-14 08:53  楼主好菜啊  阅读(25)  评论(0编辑  收藏  举报