下载地址:https://www.pan38.com/share.php?code=JCnzE 提取密码:7789
这个Auto.js脚本实现了微信自动发朋友圈的核心功能,包含UI界面、定时发送和立即发送两种模式。使用时需要确保Auto.js有必要的权限,并且微信界面没有重大更新导致UI元素ID变化。代码中图片选择部分可能需要根据实际设备调整。
/**
* 微信自动发朋友圈脚本
* 功能:定时发送文字和图片到朋友圈
* 依赖:Auto.js 4.1.0+
*/
// 主界面UI
ui.layout(
<vertical padding="16">
<text textSize="18sp" textColor="#000000" text="微信自动发朋友圈" />
<horizontal>
<text text="内容:" />
<input id="content" hint="输入朋友圈内容" layout_weight="1" />
</horizontal>
<horizontal>
<text text="图片路径:" />
<input id="imagePath" hint="输入图片路径(可选)" layout_weight="1" />
<button id="selectImage" text="选择图片" />
</horizontal>
<horizontal>
<text text="定时:" />
<timepicker id="timePicker" />
</horizontal>
<horizontal>
<button id="setNow" text="立即发送" />
<button id="setSchedule" text="定时发送" />
</horizontal>
<text id="log" text="" textColor="#888888" />
</vertical>
);
// 全局变量
let scheduledTask = null;
// 选择图片按钮点击事件
ui.selectImage.click(() => {
let path = dialogs.selectFile("选择图片", "/sdcard/", ["image/*"]);
if (path) {
ui.imagePath.setText(path);
}
});
// 立即发送按钮点击事件
ui.setNow.click(() => {
let content = ui.content.text();
let imagePath = ui.imagePath.text();
if (!content && !imagePath) {
toast("内容和图片不能同时为空");
return;
}
sendMoment(content, imagePath);
});
// 定时发送按钮点击事件
ui.setSchedule.click(() => {
let content = ui.content.text();
let imagePath = ui.imagePath.text();
let time = ui.timePicker.text;
if (!content && !imagePath) {
toast("内容和图片不能同时为空");
return;
}
// 取消之前的定时任务
if (scheduledTask) {
clearTimeout(scheduledTask);
}
// 计算定时时间
let now = new Date();
let targetTime = new Date();
targetTime.setHours(time.split(":")[0]);
targetTime.setMinutes(time.split(":")[1]);
targetTime.setSeconds(0);
if (targetTime < now) {
targetTime.setDate(targetTime.getDate() + 1);
}
let delay = targetTime - now;
// 设置定时任务
scheduledTask = setTimeout(() => {
sendMoment(content, imagePath);
}, delay);
ui.log.setText("已设置定时任务,将在 " + time + " 发送");
});
// 发送朋友圈核心函数
function sendMoment(content, imagePath) {
// 启动微信
launchApp("微信");
sleep(2000);
// 进入朋友圈
click("发现");
sleep(1000);
click("朋友圈");
sleep(2000);
// 点击相机按钮
let cameraBtn = id("com.tencent.mm:id/j5t").findOne(3000);
if (cameraBtn) {
cameraBtn.click();
sleep(1000);
// 选择发送纯文字或图文
if (imagePath) {
// 选择图片
click("从相册选择");
sleep(1000);
// 这里需要根据实际UI调整图片选择逻辑
// 假设我们已经有了图片路径
let img = images.read(imagePath);
if (img) {
// 模拟选择图片操作
// 实际实现可能需要更复杂的UI操作
// 这里简化处理
sleep(2000);
click("完成");
sleep(1000);
} else {
toast("图片加载失败");
return;
}
} else {
// 纯文字
click("这一刻的想法...");
sleep(1000);
}
// 输入内容
if (content) {
setText(content);
sleep(1000);
}
// 点击发送
click("发表");
sleep(2000);
ui.log.setText("朋友圈发送成功: " + new Date().toLocaleString());
} else {
toast("找不到朋友圈入口");
}
}
// 保持脚本运行
setInterval(() => {}, 1000);
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。