Auto Js
名称(name): |
68回复 |
大小: |
0 KB |
开发者: |
其他 |
是否开源: |
开源版 |
功能介绍: |
可以检测对话框里面的指定关键词,出现后就自动回复一条但是它不会重复回复 |
可以检测对话框里面的指定关键词,出现后就自动回复一条但是它不会重复回复,用的AUtojs版本是8.0的
- sleep(10000);
- var lastMatchBounds = null; // 用于存储上一个匹配控件的边界坐标
- // 获取控件的边界坐标
- function getWidgetBounds(widget) {
- var bounds = widget.bounds();
- return { left: bounds.left, top: bounds.top, right: bounds.right, bottom: bounds.bottom };
- }
- // 检查边界坐标是否相等
- function areBoundsEqual(bounds1, bounds2) {
- return bounds1 && bounds2 &&
- bounds1.left === bounds2.left && bounds1.top === bounds2.top &&
- bounds1.right === bounds2.right && bounds1.bottom === bounds2.bottom;
- }
- // 检查并处理控件的函数
- function checkAndProcessWidgets() {
- var widgets = find(); // 每次都重新获取最新的控件
- widgets.forEach(function(widget) {
- var text = widget.text();
- // 检查文本是否包含关键词“开始下”
- if (text.includes("开始下")) {
- var currentBounds = getWidgetBounds(widget); // 获取当前控件的边界坐标
- // 检查当前控件的边界坐标是否与上一个匹配的不同
- if (!areBoundsEqual(currentBounds, lastMatchBounds)) {
- console.log("成功:找到新的匹配项!");
- toast("准备回复");
- // 执行回复操作
- performReplyActions();
- // 重新获取控件并更新lastMatchBounds
- var newWidgets = find();
- newWidgets.forEach(function(newWidget) {
- if (newWidget.text().includes("开始下")) {
- lastMatchBounds = getWidgetBounds(newWidget);
- }
- });
- }
- }
- });
- }
- function performReplyActions() {
- // 等待时间
- sleep(1600);
- id("editTextMessage").findOne(1000).click();
- sleep(2000);
- // 发送消息
- hs="333@456@666@999"
- let parts = hs.split('@');
- // 随机选择一个分割后的元素
- let randomIndex = Math.floor(Math.random() * parts.length);
- let randomPart = parts[randomIndex];
- // 输出随机选择的元素
- console.log(randomPart);
- //随机话术
- setText(randomPart);
- sleep(1600);
- // 寻找“发送”按钮控件
- var imageSend = id("imageSend").findOne(1000);
- if (imageSend != null) {
- // 获取控件的边界
- var bounds = imageSend.bounds();
-
- // 计算中心点坐标
- var centerX = bounds.left + (bounds.width() / 2);
- var centerY = bounds.top + (bounds.height() / 2);
- // 执行坐标点击
- click(centerX, centerY);
- sleep(1600);
- back();
- sleep(1600);
- } else {
- console.log("控件未找到");
- }
- }
- // 首次执行
- checkAndProcessWidgets();
- // 设置一个定时器,定期检查新的控件
- setInterval(function() {
- checkAndProcessWidgets();
- }, 1000); // 每隔1000毫秒(1秒)执行一次
复制代码
|
上一篇:易语言开发的抖音评论采集工具,完全分享源码下一篇:易语言宽带拨号vps一键换IP代码分享
|