求一个支付宝收取能量的脚本

我自己测试的时候总是没有办法点击能量球,求点击能量球的办法

区域全点。

@卢某某 如何区域全点,我试了试自己写的点击位置的click 不知道为什么对应用不起作用

var smallHandPic = images.read("/sdcard/take.png");

if (!smallHandPic) {
toastLog("缺少图片文件");
switch (device.width) {
case 1080:
smallHandPic = images.load("https://raw.githubusercontent.com/start201711/autojs/master/take.png");
break;
case 720:
smallHandPic = images.load("https://raw.githubusercontent.com/start201711/autojs/master/take720p.png");
break;
default:
smallHandPic = null;
break;
}

if (!smallHandPic) {
    toastLog("尝试下载take.png失败,脚本停止运行");
    exit();
}
toastLog("现在将尝试使用别人的图片,分辨率可能不匹配,脚本可能无法正常执行");

}
var r = new Robot();
var dh = 50 * device.height / 1920;

//向系统申请截图时,自动确认
// new java.lang.Thread(function() {
// classNameContains("Button").textContains("立即开始").click();
// }).start();

if (!requestScreenCapture()) {
toastLog("请求截图失败");
exit();
}
toastLog("即将收取蚂蚁森林能量,请勿操作!");

launch("com.eg.android.AlipayGphone");
waitForPackage("com.eg.android.AlipayGphone");

//这里使用一个兼容的办法clickSenlin();
clickSenlin(); //兼容方法

//收取自己的能量
collect(true);

//开始下滑匹配小手
while (true) {
for (var p = findImage(captureScreen(), smallHandPic); p; p = findImage(captureScreen(), smallHandPic)) {

    r.press(p.x, p.y + dh, 100);

    collect(false);

}

if (descContains("爱心捐赠").find().size() > 0) {
    if (descContains("爱心捐赠").findOne().bounds().top < device.height) {
        break;
    }
}

r.swipe(device.width / 3, device.height *3/4, device.width / 3, device.height /4,10);
sleep(300);

}

//点击更多按钮
var more = descContains("查看更多好友").findOne();
r.pressCenter(more);
sleep(1000);

while (true) {

for (var p = findImage(captureScreen(), smallHandPic); p; p = findImage(captureScreen(), smallHandPic)) {

    r.press(p.x, p.y + dh, 100);

    collect(false);
}

if (descContains("没有更多了").find().size() > 0) {
    if (descContains("没有更多了").findOne().bounds().top < device.height) {
        break;
    }
}
r.swipe(device.width / 3, device.height *3/4, device.width / 3, device.height /4,40);
sleep(300);

}
idContains("h5_tv_nav_back").click();
toastLog("收取能量完毕");
idContains("h5_tv_nav_back").click();
exit();

//收能量方法
function collect(isMyself) {

if(isMyself){

    className("android.widget.Button").desc("攻略").waitFor();
    sleep(1500);

    var myPower1 = descContains('线下支付');
    var myPower2 = descContains('行走');
    log("自己能量泡个数:"+myPower1.find().size()+myPower2.find().size());
    for (var i = 0; i < myPower1.find().size(); i++) {

        var ClickX = myPower1.find().get(i).bounds().centerX();
        var ClickY = myPower1.find().get(i).bounds().centerY();
        click(ClickX,ClickY-dh);
        sleep(500);
    }
    for (var i = 0; i < myPower2.find().size(); i++) {

        var ClickX = myPower2.find().get(i).bounds().centerX();
        var ClickY = myPower2.find().get(i).bounds().centerY();
        click(ClickX,ClickY-dh);
        sleep(500);
    }

}else{
    className("android.widget.Button").desc("浇水").waitFor();
    sleep(1500);

    var friendPower = descContains('可收取');
    log("好友能量泡个数:"+friendPower.find().size());
    for (var i = 0; i < friendPower.find().size(); i++) {

        var ClickX = friendPower.find().get(i).bounds().centerX();
        var ClickY = friendPower.find().get(i).bounds().centerY();
        click(ClickX,ClickY-dh);
        sleep(500);
    }

    idContains("h5_tv_nav_back").click();
    sleep(500);
}

}

function clickSenlin() {
var b = text("蚂蚁森林").findOne().bounds();
var a = idContains("home_app_view").untilFind().filter(o => {
return o.bounds().contains(b);
});
while (!a[0].click());
}

function Robot() {
var r = null;
if (device.sdkInt < 24) {
if (isRoot()) {
r = new RootAutomator();
} else {
toastLog("本脚本需要android7.0以上或者已root才能使用");
exit();
}
}

this.press = function(x, y, duration) {
    if (duration == undefined) {
        duration = 100;
    }
    if (r == null) {
        press(x, y, duration);
    } else {
        r.press(x, y, duration);
    }
}
this.pressCenter = function(b, duration) {
    this.press(b.bounds().centerX(), b.bounds().centerY(), duration);
}
this.swipe = function(x1, y1, x2, y2, duration) {
    if (duration == undefined) {
        duration = 200;
    }
    if (r == null) {
        swipe(x1, y1, x2, y2, duration);
    } else {
        var n = 30;
        var dx = (x2 - x1) / n;
        var dy = (y2 - y1) / n;
        r.touchDown(x1, y1);
        for (var i = 0; i < n; i++) {
            r.touchMove(x1, y1);
            x1 += 6 * dx * i * (n - i) / Math.pow(n, 2);
            y1 += 6 * dy * i * (n - i) / Math.pow(n, 2);
            sleep(duration / n);
        }
        r.touchUp();
    }
}

}

function isRoot() {
var bool = false;
try {
bool = new java.io.File("/system/bin/su").exists() || new java.io.File("/system/xbin/su").exists();
} catch (e) {
print(e);
}
return bool;
}

  • 5
    帖子
  • 1311
    浏览

与 Auto.js 的连接断开,我们正在尝试重连,请耐心等待