星空软件

 找回密码
 立即注册

安卓关键词监控自动回复脚本,AUTOJS,只回复一条代码

a992930143 | 2024-1-28 21:41:29 | 显示全部楼层 |阅读模式
Auto Js
名称(name): 68回复
大小: 0 KB
开发者: 其他
是否开源: 开源版
功能介绍: 可以检测对话框里面的指定关键词,出现后就自动回复一条但是它不会重复回复
可以检测对话框里面的指定关键词,出现后就自动回复一条但是它不会重复回复,用的AUtojs版本是8.0的
  1. sleep(10000);

  2. var lastMatchBounds = null; // 用于存储上一个匹配控件的边界坐标

  3. // 获取控件的边界坐标
  4. function getWidgetBounds(widget) {
  5.     var bounds = widget.bounds();
  6.     return { left: bounds.left, top: bounds.top, right: bounds.right, bottom: bounds.bottom };
  7. }

  8. // 检查边界坐标是否相等
  9. function areBoundsEqual(bounds1, bounds2) {
  10.     return bounds1 && bounds2 &&
  11.            bounds1.left === bounds2.left && bounds1.top === bounds2.top &&
  12.            bounds1.right === bounds2.right && bounds1.bottom === bounds2.bottom;
  13. }

  14. // 检查并处理控件的函数
  15. function checkAndProcessWidgets() {
  16.     var widgets = find(); // 每次都重新获取最新的控件
  17.     widgets.forEach(function(widget) {
  18.         var text = widget.text();

  19.         // 检查文本是否包含关键词“开始下”
  20.         if (text.includes("开始下")) {
  21.             var currentBounds = getWidgetBounds(widget); // 获取当前控件的边界坐标

  22.             // 检查当前控件的边界坐标是否与上一个匹配的不同
  23.             if (!areBoundsEqual(currentBounds, lastMatchBounds)) {
  24.                 console.log("成功:找到新的匹配项!");
  25.                 toast("准备回复");

  26.                 // 执行回复操作
  27.                 performReplyActions();

  28.                 // 重新获取控件并更新lastMatchBounds
  29.                 var newWidgets = find();
  30.                 newWidgets.forEach(function(newWidget) {
  31.                     if (newWidget.text().includes("开始下")) {
  32.                         lastMatchBounds = getWidgetBounds(newWidget);
  33.                     }
  34.                 });
  35.             }
  36.         }
  37.     });
  38. }

  39. function performReplyActions() {
  40.     // 等待时间
  41.     sleep(1600);
  42.     id("editTextMessage").findOne(1000).click();
  43.     sleep(2000);

  44.     // 发送消息
  45.     hs="333@456@666@999"
  46.     let parts = hs.split('@');

  47. // 随机选择一个分割后的元素
  48. let randomIndex = Math.floor(Math.random() * parts.length);
  49. let randomPart = parts[randomIndex];

  50. // 输出随机选择的元素
  51. console.log(randomPart);
  52. //随机话术


  53. setText(randomPart);
  54.     sleep(1600);

  55.     // 寻找“发送”按钮控件
  56.     var imageSend = id("imageSend").findOne(1000);
  57.     if (imageSend != null) {
  58.         // 获取控件的边界
  59.         var bounds = imageSend.bounds();
  60.         
  61.         // 计算中心点坐标
  62.         var centerX = bounds.left + (bounds.width() / 2);
  63.         var centerY = bounds.top + (bounds.height() / 2);

  64.         // 执行坐标点击
  65.         click(centerX, centerY);
  66.         sleep(1600);
  67.         back();
  68.         sleep(1600);
  69.     } else {
  70.         console.log("控件未找到");
  71.     }
  72. }

  73. // 首次执行
  74. checkAndProcessWidgets();

  75. // 设置一个定时器,定期检查新的控件
  76. setInterval(function() {
  77.     checkAndProcessWidgets();
  78. }, 1000); // 每隔1000毫秒(1秒)执行一次
复制代码






上一篇:易语言开发的抖音评论采集工具,完全分享源码
下一篇:易语言宽带拨号vps一键换IP代码分享
回复

使用道具 举报

siduan | 2024-1-28 21:41:53 | 显示全部楼层
不错
回复

使用道具 举报

2381560 | 2024-1-28 21:41:57 | 显示全部楼层
可以用
回复

使用道具 举报

arawihak | 2024-1-28 21:42:02 | 显示全部楼层
试过了
回复

使用道具 举报

htf320032 | 2024-1-28 21:42:05 | 显示全部楼层
可以的
回复

使用道具 举报

ilegoz | 2024-1-28 21:42:08 | 显示全部楼层
感谢分享
回复

使用道具 举报

w584518 | 2024-1-28 21:42:26 | 显示全部楼层
这个挺好玩
回复

使用道具 举报

815867999 | 2024-1-28 21:42:40 | 显示全部楼层
通过坐标变化来回复的
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

全站声明【必看】|小黑屋|新库软件 |网站地图

GMT+8, 2024-4-29 02:57 , Processed in 0.065809 second(s), 28 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.