下载地址:www.pan38.com/dow/share.p… 提取密码:1829
代码说明:这个AutoJS脚本实现了拼多多商家私信群发功能,包含UI界面、商家搜索、私信发送等完整流程。使用时需要安装AutoJS并开启无障碍服务。注意实际使用时可能需要根据APP版本调整元素定位方式。
` // 拼多多商家私信自动化脚本 // 需要AutoJS 4.1.1以上版本支持 "ui"; ui.layout( );
let running = false; const MAX_RETRY = 3; let currentPage = 1;
// 主逻辑函数 function mainProcess() { let keywords = ui.keywords.text(); let message = ui.message.text(); let interval = parseInt(ui.interval.text()) * 1000;
// 打开拼多多商家版APP
launchApp("拼多多商家版");
waitForPackage("com.xunmeng.pinduoduo");
sleep(3000);
// 搜索商家
click(device.width/2, 150); // 点击搜索框
setText(keywords);
press('Enter');
sleep(2000);
// 循环处理商家列表
while(running) {
let shops = findShops();
if(shops.length === 0) {
swipe(device.width/2, device.height*0.7,
device.width/2, device.height*0.3, 500);
sleep(1000);
continue;
}
for(let i = 0; i < shops.length && running; i++) {
let shop = shops[i];
click(shop.bounds().centerX(), shop.bounds().centerY());
sleep(2000);
// 发送私信
if(sendMessage(message)) {
ui.run(() => ui.log.setText("成功发送给: " + shop.text()));
back();
sleep(interval);
} else {
ui.run(() => ui.log.setText("发送失败: " + shop.text()));
}
}
// 翻页
swipe(device.width/2, device.height*0.7,
device.width/2, device.height*0.3, 500);
sleep(1000);
currentPage++;
}
}
// 查找商家元素 function findShops() { let shops = []; let retry = 0;
while(retry < MAX_RETRY && shops.length === 0) {
shops = className("android.widget.TextView")
.textMatches(".*店铺.*")
.find();
if(shops.length === 0) {
sleep(1000);
retry++;
}
}
return shops;
}
// 发送私信 function sendMessage(msg) { let contactBtn = text("联系商家").findOne(3000); if(!contactBtn) return false;
click(contactBtn.bounds().centerX(), contactBtn.bounds().centerY());
sleep(2000);
let input = className("android.widget.EditText").findOne(3000);
if(!input) return false;
setText(msg);
sleep(500);
let sendBtn = text("发送").findOne(2000);
if(!sendBtn) return false;
click(sendBtn.bounds().centerX(), sendBtn.bounds().centerY());
sleep(1000);
return true;
}
// 按钮事件 ui.start.click(() => { running = true; ui.start.enabled = false; ui.stop.enabled = true; threads.start(mainProcess); });
ui.stop.click(() => { running = false; ui.start.enabled = true; ui.stop.enabled = false; ui.log.setText("已停止发送"); }); `