注册时间
最后登录

签名档

欢迎加入autojs资料收集,群聊号码:703407652

关于我

欢迎加入autojs资料收集,群聊号码:703407652

新帖
发布在 一般交流 阅读更多

作者说captureScreen();不需要回收
你把img.recycle();删掉就可以了

发布在 一般交流 阅读更多

@哥不帅却很坏如何写判定脚本 中说:

比如说判定屏幕x500y500。如果是红色,点击屏幕x100y300,如果不是,继续循环上面步骤。
手机没法root。求大神每个案例解释下。

if (!requestScreenCapture()) {
  toast("请求截图失败");
  exit();
}
var xInspect = 500
var yInspect = 500
var colorRed = '#ff0000'
var xClick = 100
var yClick = 300
while (1) {
  //获取在点(100, 100)的颜色值
  var img = captureScreen();
  var color = images.pixel(img, xInspect, yInspect);
  var result = colors.isSimilar(color, colorRed)
  if (result) {
    press(xClick, yClick, 1)
    break;
  }
  img.recycle();
  sleep(300)
}

发布在 脚本需求 阅读更多

长按 就可以调整位置和大小了

发布在 脚本需求 阅读更多
//这里修改你要运行的脚本

var path = "/sdcard/脚本/111.js";
if(!files.exists(path)){
    toast("脚本文件不存在: " + path);
    exit();
}
var window = floaty.window(
    <frame>
        <button id="action" text="开始运行" w="90" h="40" bg="#cc66ffff" layout_width="match_parent" layout_height="match_parent"/>
    </frame>
);

window.exitOnClose();
var x=device.width/3
var y=device.height/3
window.setPosition(x,y)
var execution = null;

window.action.click(()=>{
    if(window.action.getText() == '开始运行'){
        execution = engines.execScriptFile(path);
        window.action.setText('停止运行');
    }else{
        if(execution){
            execution.getEngine().forceStop();
        }
        window.action.setText('开始运行');
    }
});

window.action.longClick(()=>{
   window.setAdjustEnabled(!window.isAdjustEnabled());
   return true;
});

setInterval(()=>{}, 1000);

发布在 脚本发布 阅读更多

@nice-strange
论坛都要关了

没地方分享代码了

没地方学习代码了

发布在 脚本需求 阅读更多
var path = '/data/user/0/com.tencent.mobileqq/guid'
r = readFile(path)
log(r)
writeFile(path, 'dsfsfdsafasfds')
r = readFile(path)
log(r)

function readFile(path) {
  var sh = new Shell(true);
  var tempFile = '/sdcard/temp.txt'
  sh.exec('cat ' + path + '> ' + tempFile)
  sh.exitAndWaitFor()
  return files.read(tempFile)
}

function writeFile(path, content) {
  var tempFile = '/sdcard/temp.txt'
  files.createWithDirs(tempFile)
  files.write(tempFile, content)
  var sh = new Shell(true);
  sh.exec('cat ' + tempFile + ' > ' + path)
  sh.exitAndWaitFor()
}
发布在 脚本发布 阅读更多
// 设置画笔的样式,为FILL,FILL_AND_STROKE,或STROKE
var Feis = {
  Color: android.graphics.Color,
  Color_toARGB: function (color) {
    return [Feis.Color.alpha(color), Feis.Color.red(color), Feis.Color.green(color), Feis.Color.blue(color)];
  }
}
var width = device.width
var height = device.height
var MARGIN_TOP = 60;
var MARGIN_LEFT = 30;
var BG_COLOR = '#ff00ff00'
BG_COLOR = colors.parseColor(BG_COLOR)
var window = floaty.rawWindow( <canvas id = "board"
  h = "{{device.height}}"
  w = "{{device.width}}"
  />
);
window.setTouchable(false);
setInterval(() => {}, 3000)
var path = new android.graphics.Path();
var paint = new android.graphics.Paint;
paint.setStrokeWidth(5);
paint.setTextAlign(Paint.Align.CENTER);
paint.setColor(-28707)
paint.setStyle(Paint.Style.STROKE);
window.board.on("draw", function (canvas) {
  var argb = Feis.Color_toARGB(BG_COLOR)
  canvas.drawARGB(argb[0], argb[1], argb[2], argb[3]);
  path.reset();
  path.moveTo(75, 15);
  path.quadTo(220, 26, 220, 160);
  canvas.drawPath(path, paint);
  path.moveTo(219, 141);
  path.quadTo(240, 300, 70, 250);
  canvas.drawPath(path, paint);
  path.moveTo(76, 253);
  path.quadTo(16, 220, 74, 111);
  canvas.drawPath(path, paint);
  quadraticCurveTo(canvas, [
    73, 112, 60, 112, 31, 83
  ])
  quadraticCurveTo(canvas, [
    31, 83, 23, 26, 75, 15
  ])
  quadraticCurveTo(canvas, [
    75, 15, 108, 32, 99, 61
  ])
  quadraticCurveTo(canvas, [
    99, 61, 66, 101, 31, 81
  ])
  color = '#E47A8B'
  color = colors.parseColor(color)
  paint.setColor(color)
  paint.setStyle(Paint.Style.FILL_AND_STROKE);
  arcRect = new android.graphics.RectF(42, 42, 54, 54);
  canvas.drawArc(arcRect, 180 / Math.PI * 0 * Math.PI, 180 / Math.PI * 2.5 * Math.PI, false, paint)
  arcRect = new android.graphics.RectF(71, 42, 83, 54);
  canvas.drawArc(arcRect, 180 / Math.PI * 0 * Math.PI, 180 / Math.PI * 2.5 * Math.PI, false, paint)
  paint.setStyle(Paint.Style.STROKE);
  quadraticCurveTo(canvas, [
    149, 31, 155, 0, 189, 6
  ])
  quadraticCurveTo(canvas, [
    189, 6, 188, 30, 170, 44
  ])
  quadraticCurveTo(canvas, [
    188, 59, 198, 24, 222, 32
  ])
  quadraticCurveTo(canvas, [
    222, 32, 255, 54, 199, 75
  ])
  arcRect = new android.graphics.RectF(63, 148, 123, 208);
  canvas.drawArc(arcRect, 180 / Math.PI * 0 * Math.PI, 180 / Math.PI * 2.5 * Math.PI, false, paint)
  color = '#E47A8B'
  paint.setColor(colors.parseColor(color))
  arcRect = new android.graphics.RectF(127, 53, 155, 81);
  canvas.drawArc(arcRect, 180 / Math.PI * 0 * Math.PI, 180 / Math.PI * 2.5 * Math.PI, false, paint)
  color = "#E47A8B"
  paint.setColor(colors.parseColor(color))
  arcRect = new android.graphics.RectF(156, 74, 184, 102);
  canvas.drawArc(arcRect, 180 / Math.PI * 0 * Math.PI, 180 / Math.PI * 2.5 * Math.PI, false, paint)
  color = "#000000"
  paint.setColor(colors.parseColor(color))
  paint.setStyle(Paint.Style.FILL);
  arcRect = new android.graphics.RectF(130, 58, 142, 70);
  canvas.drawArc(arcRect, 180 / Math.PI * 0 * Math.PI, 180 / Math.PI * 2.5 * Math.PI, false, paint)
  color = "#000000"
  paint.setColor(colors.parseColor(color))
  arcRect = new android.graphics.RectF(159, 81, 171, 93);
  canvas.drawArc(arcRect, 180 / Math.PI * 0 * Math.PI, 180 / Math.PI * 2.5 * Math.PI, false, paint)
  color = "#CD8C95"
  paint.setColor(colors.parseColor(color))
  arcRect = new android.graphics.RectF(158, 127, 198, 167);
  canvas.drawArc(arcRect, 180 / Math.PI * 0 * Math.PI, 180 / Math.PI * 2.5 * Math.PI, false, paint)
  paint.setStyle(Paint.Style.STROKE);
  quadraticCurveTo(canvas, [
    195, 245, 215, 215, 244, 410
  ])
  quadraticCurveTo(canvas, [
    244, 410, 244, 410, 38, 410
  ])
  quadraticCurveTo(canvas, [
    38, 410, 11, 410, 76, 251
  ])
  color = "#FFB2E0"
  paint.setColor(colors.parseColor(color))
  quadraticCurveTo(canvas, [
    58, 294, 50, 288, 12, 238
  ])
  quadraticCurveTo(canvas, [
    56, 300, 56, 300, 16, 260
  ])
  canvas.drawLine(16, 260, 3, 269, paint);
  canvas.drawLine(3, 269, 11, 250, paint);
  canvas.drawLine(11, 250, 3, 228, paint);
  canvas.drawLine(3, 228, 15, 241, paint);
  quadraticCurveTo(canvas, [
    223, 292, 266, 288, 287, 271
  ])
  quadraticCurveTo(canvas, [
    287, 271, 236, 233, 279, 245
  ])
  quadraticCurveTo(canvas, [
    279, 245, 255, 200, 295, 247
  ])
  quadraticCurveTo(canvas, [
    295, 247, 288, 200, 306, 226
  ])
  quadraticCurveTo(canvas, [
    306, 226, 311, 250, 308, 248
  ])
  quadraticCurveTo(canvas, [
    308, 248, 344, 200, 334, 245
  ])
  quadraticCurveTo(canvas, [
    334, 245, 311, 280, 300, 280
  ])
  quadraticCurveTo(canvas, [
    300, 280, 311, 280, 224, 303
  ])
  quadraticCurveTo(canvas, [
    94, 409, 94, 409, 96, 451
  ])
  quadraticCurveTo(canvas, [
    96, 451, 53, 429, 56, 461
  ])
  quadraticCurveTo(canvas, [
    56, 461, 56, 461, 107, 464
  ])
  canvas.drawLine(107, 464, 106, 409, paint);
  canvas.drawLine(106, 409, 183, 411, paint);
  canvas.drawLine(183, 411, 182, 447, paint);
  quadraticCurveTo(canvas, [
    182, 447, 124, 434, 136, 464
  ])
  canvas.drawLine(136, 464, 196, 463, paint);
  canvas.drawLine(196, 463, 195, 409, paint);
  paint.setStrokeWidth(7);
  paint.setColor(-25398)
  quadraticCurveTo(canvas, [
    238, 360, 266, 380, 267, 360
  ])
  quadraticCurveTo(canvas, [
    267, 360, 254, 330, 250, 380
  ])
  quadraticCurveTo(canvas, [
    250, 380, 254, 420, 290, 369
  ])
})

function printObj(obj) {
  for (var k in obj) {
    log(k)
  }
}

function quadraticCurveTo(canvas, xyArr) {
  path.moveTo(xyArr[0], xyArr[1]);
  path.quadTo(xyArr[2], xyArr[3], xyArr[4], xyArr[5]);
  canvas.drawPath(path, paint);
}


发布在 一般交流 阅读更多

tasker可以开机自动在后台打开autojs的无障碍

发布在 脚本发布 阅读更多

完全按照你的要求做的, 不过真的能用吗?

发布在 脚本发布 阅读更多
// 双击(550,798)
// 然后停留30秒(这里能搞随机停留最好了)
// 按一下返回键
// 从(697,1660)上滑至(697,725)
// 然后重复上面的
while (1) {
  main()
}

function main() {
  双击()
  停留30秒()
  back()
  swipe(697, 1660, 697, 725, 300)
}

function 双击() {
  var x = 550
  var y = 798
  press(x, y, 1)
  sleep(100)
  press(x, y, 1)
  sleep(100)
}

function 停留30秒() {
  var rndTime = random(500, 3000)
  sleep(30 * 1000 + rndTime)
}


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