软件经常执行脚本一分钟左右就自动退出,后台已锁
小米note3,安卓8.1,还有找色问题,经常返回img为null

@admin 4.0.1 Beta,4.0.4那里有,检查提示最新,酷安无更新

开发者

@qwe-6

function capture(){
   var img;
   while((img = captureScreen() == null);
   return img;
}
``
暂时用这个代码代替截屏

@admin 用不了,闪退问题怎么解决,就不运行脚本软件一直在后台,运行脚本大概率退出,脚本在下面

if (!requestScreenCapture()) {
toast("请求截图失败");
exit();
}

threads.start(function() {
q = ["自捐", "辅捐", "采集"]
w = dialogs.singleChoice("战火辅助", q)
switch (w) {
case 0:
自捐();
break;
case 1:
辅捐();
break;
case 2:
采集();
break;
default:
toast("退出")
exit()
}
})

function 采集() {
while (true) {
var q = findMultiColors(captureScreen(), "#ffbf9d5d", [
[19, -10, "#ffe1bd7b"],
[19, 13, "#ff8e6e33"]
], {
region: [0, 0, 1080, 960]
});
if (q != null) {
log(q)
click(q.x + 10, q.y + 10)
sleep(500);
click(q.x + 10, q.y + 10)
sleep(1000);
click(540, 535);
sleep(500);
click(550, 1835);
sleep(1000);
click(775, 1765);
sleep(2000);
click(670, 1410);
sleep(500);
click(980, 1875);

    }
}

}

function 划地图() {
for (var q = 190; q < 1110; q += 10) {
for (var i = 100; i < 1110; i += 10) {
sleep(500)
click(600, 1635)
sleep(150)
click(390, 935)
sleep(150)
setText(q)
sleep(150)
click("确定")
sleep(150)
click(750, 935)
sleep(150)
setText(i)
click("确定")
sleep(200)
click(540, 1140)
sleep(1000);
var img = captureScreen();
var x = images.detectsColor(img, "#ff661606", 350, 1280)
if (x) {
click(550, 1700);
}
}
}
}

function 检查() {
while (true) {
var t = images.detectsColor(captureScreen(), "#ff69bc23", 445, 1400)
var y = images.detectsColor(captureScreen(), "#ff00212f", 870, 120)
var u = images.detectsColor(captureScreen(), "#ff3b0202", 240, 240)
if (t) {
sleep(1000);
click(445, 1400);
sleep(1000);
click(445, 1400);
sleep(1000);
break
} else if (y) {
sleep(1000)
if (images.detectsColor(captureScreen(), "#ff69bc23", 445, 1400)) {
click(445, 1400);
sleep(500);
click(445, 1400);
sleep(500);
}
break
} else {
if (u) {
sleep(500);
click(1016, 245);
sleep(500);
break
}
}
}
}

function 捐献() {
click(840, 1870);
sleep(500);
click(500, 1150);
sleep(1000);
click(150, 640);
sleep(1000);
for (var i = 1; i < 5; i++) {
click(310, 1230);
sleep(1000)
}
click(350, 1050);
sleep(500);
click(940, 535);
sleep(500);
click(80, 90);
sleep(500);
click(80, 90);
sleep(500);
}

function VIP检查() {
if (images.detectsColor(captureScreen(), "#ff6f0908", 595, 95)) {
toastLog("已开VIP")
sleep(500);
} else {
toastLog("未开VIP,激活中");
sleep(500);
click(595, 95);
sleep(500);
click(400, 210);
sleep(500);
click(950, 460); //激活
sleep(500);
click(550, 1030); //确认
sleep(500);
click(80, 90); //返回
sleep(500)
click(80, 90); //返回
sleep(500);
}
}

function 自捐() {
for (var q = 160; q < 1000; q += 255) {
for (var w = 160; w < 1000; w += 255) {
sleep(1000)
click(q, w)
sleep(5000)
a = "com.miui.home"
s = currentPackage()
if (s == a) {
log("闪退,重启")
click(q, w)
}
检查()
捐献()
home()

    }
}

}

function 辅捐() {
while (true) {
检查();
捐献();
home();
sleep(500);
}
}

function不能用中文命名

不要直接用captureScreen();
images.detectsColor(captureScreen(), "#ff3b0202", 240, 240);这样子写很不稳定!

function capture(){
var img;
while((img = captureScreen() == null);
return img;
}
var img = captur();
images.detectsColor( img, "#ff3b0202", 240, 240);这样子写很不稳定!
我都不知道踩了多少次雷坑了。(ノへ ̄、)

@lailer132 用了你的代码,报错18:18:14.959/ E: missing) after condition
这个书写方式是因为即兴写的,脚本测试完毕直接包装放进去,没有调整,关于中文,我记得好像在教程里看到过可以随意备注,包括中文

  • 13
    帖子
  • 3545
    浏览

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