Auto.js微信抢红包脚本

launchApp("微信")
toastLog("准备抢红包,请将屏幕保持在微信的聊天窗口")
device.keepScreenOn()

//搜索新红包并点开领取
function searchNewRedpacket () {
     
  var rp_msg_list = className("android.widget.TextView").id('u1').find();
  if (rp_msg_list.length != 0) {
     
    log("检测到的红包个数: " + rp_msg_list.length);
    for (var i = 0; i < rp_msg_list.length; i++) {
     
      var rp_u1 = rp_msg_list[i];
      var rp_u1_parent = rp_u1.parent()
      if (rp_u1_parent != null && rp_u1_parent.childCount() == 1) {
     
        log("发现新红包");
        click(rp_u1.bounds().centerX(), rp_u1.bounds().centerY())
        openNewRedPacket();
      }

    }
  } else if (rp_msg_list.empty()) {
     
    log("未检测到红包消息" + rp_msg_list.length);
  } else {
     
    return;
  }
}

//领取点开的红包
function openNewRedPacket () {
     
  var draw = desc("开").findOne(500);
  if (draw != null) {
     
    log("点开新红包");
    draw.click();
    sleep(1000);
    back();
  } else {
     
    log("过期之类无效红包");
  }
  back();
  log("返回成功");
}


while (true) {
     
  searchNewRedpacket()
  sleep(1000)
}

这里是已经打包好的apk
https://download.csdn.net/download/jason_9527/15201360
请不要用于商业用途

你可能感兴趣的:(杂七杂八)