下载地址:https://www.pan38.com/share.php?code=n6cPZ 提取码:8888 【声明:仅供学习参考】
/**
* 微信养号自动化脚本
* 功能:自动浏览朋友圈、公众号文章、新闻等
*/
// 初始化配置
let config = {
scrollCount: 10, // 每次滚动次数
scrollDelay: 2000, // 滚动间隔(ms)
readTime: 15000, // 阅读时长(ms)
maxRunTime: 3600000 // 最大运行时长(ms,1小时)
};
// 主函数
function main() {
auto.waitFor();
console.show();
log("微信养号脚本启动");
let startTime = new Date().getTime();
while (new Date().getTime() - startTime < config.maxRunTime) {
// 随机选择功能
let funcIndex = random(1, 3);
switch(funcIndex) {
case 1:
browseMoments();
break;
case 2:
browseNews();
break;
case 3:
browseArticles();
break;
}
sleep(random(5000, 10000)); // 随机间隔
}
log("脚本运行完成");
}
// 浏览朋友圈
function browseMoments() {
log("开始浏览朋友圈");
launchApp("微信");
waitForActivity("com.tencent.mm.ui.LauncherUI");
// 点击发现tab
let discovery = id("com.tencent.mm:id/f3y").findOne();
if (discovery) {
discovery.click();
sleep(2000);
// 点击朋友圈
let moments = text("朋友圈").findOne();
if (moments) {
moments.click();
sleep(3000);
// 模拟滚动浏览
for (let i = 0; i < config.scrollCount; i++) {
scrollDown();
sleep(config.scrollDelay);
}
}
}
log("朋友圈浏览完成");
}
// 浏览新闻
function browseNews() {
log("开始浏览新闻");
launchApp("微信");
waitForActivity("com.tencent.mm.ui.LauncherUI");
// 点击订阅号
let subscription = text("订阅号").findOne();
if (subscription) {
subscription.click();
sleep(2000);
// 随机选择一个订阅号
let accounts = className("android.widget.TextView").find();
if (accounts && accounts.length > 0) {
let randomAccount = accounts[random(0, accounts.length - 1)];
randomAccount.click();
sleep(3000);
// 随机选择一篇文章
let articles = className("android.widget.LinearLayout").find();
if (articles && articles.length > 0) {
let randomArticle = articles[random(0, articles.length - 1)];
randomArticle.click();
sleep(config.readTime);
// 模拟阅读行为
for (let i = 0; i < 3; i++) {
scrollDown();
sleep(2000);
}
}
}
}
log("新闻浏览完成");
}
// 浏览公众号文章
function browseArticles() {
log("开始浏览公众号文章");
launchApp("微信");
waitForActivity("com.tencent.mm.ui.LauncherUI");
// 点击搜索
let search = id("com.tencent.mm:id/f3n").findOne();
if (search) {
search.click();
sleep(2000);
// 输入公众号名称
let input = id("com.tencent.mm:id/bhn").findOne();
if (input) {
input.setText("人民日报");
sleep(2000);
// 点击搜索按钮
let searchBtn = id("com.tencent.mm:id/cj7").findOne();
if (searchBtn) {
searchBtn.click();
sleep(3000);
// 进入公众号
let officialAccount = text("进入公众号").findOne();
if (officialAccount) {
officialAccount.click();
sleep(3000);
// 浏览历史文章
let history = text("查看历史消息").findOne();
if (history) {
history.click();
sleep(5000);
// 随机滚动浏览
for (let i = 0; i < config.scrollCount; i++) {
scrollDown();
sleep(config.scrollDelay);
}
}
}
}
}
}
log("公众号文章浏览完成");
}
// 辅助函数:向下滚动
function scrollDown() {
let width = device.width;
let height = device.height;
swipe(width / 2, height * 0.7, width / 2, height * 0.3, 500);
}
// 启动脚本
main();
Ui:
/**
* 微信养号脚本UI控制模块
* 功能:提供可视化操作界面及状态监控
*/
// UI主界面布局
function createMainUI() {
let ui = {
title: "微信养号助手 v2.1",
width: device.width,
height: device.height,
config: {
theme: "light",
bg: "#f5f5f5"
},
views: [
// 顶部状态栏
{
type: "view",
layout: "horizontal",
width: "match",
height: 60,
bg: "#07C160",
children: [
{
type: "text",
text: "微信养号助手",
size: 20,
color: "#ffffff",
marginLeft: 15,
gravity: "center_vertical"
},
{
type: "text",
text: "已运行: 0分钟",
id: "runtime",
size: 14,
color: "#ffffff",
marginRight: 15,
gravity: "center_vertical|right"
}
]
},
// 功能按钮区
{
type: "view",
layout: "horizontal",
width: "match",
height: 120,
marginTop: 10,
children: [
{
type: "button",
text: "开始养号",
id: "start_btn",
width: "auto",
height: "auto",
margin: 10,
bg: "#07C160",
color: "#ffffff"
},
{
type: "button",
text: "停止",
id: "stop_btn",
width: "auto",
height: "auto",
margin: 10,
bg: "#FF4D4F",
color: "#ffffff"
},
{
type: "button",
text: "设置",
id: "config_btn",
width: "auto",
height: "auto",
margin: 10,
bg: "#1890FF",
color: "#ffffff"
}
]
},
// 任务状态显示
{
type: "view",
layout: "vertical",
width: "match",
height: "auto",
margin: 10,
bg: "#ffffff",
corner: 5,
children: [
{
type: "text",
text: "当前任务状态",
size: 16,
margin: 10,
bold: true
},
{
type: "text",
text: "未运行",
id: "task_status",
size: 14,
marginLeft: 15,
marginBottom: 10
},
{
type: "progress",
id: "task_progress",
width: "90%",
height: 10,
margin: 15,
progress: 0
}
]
},
// 日志输出区
{
type: "view",
layout: "vertical",
width: "match",
height: 300,
margin: 10,
bg: "#ffffff",
corner: 5,
children: [
{
type: "text",
text: "运行日志",
size: 16,
margin: 10,
bold: true
},
{
type: "scroll",
width: "match",
height: "match",
children: [
{
type: "text",
text: "",
id: "log_content",
size: 12,
margin: 10,
width: "match"
}
]
}
]
}
]
};
return ui;
}
// 设置界面
function createConfigUI() {
let config = getConfig(); // 获取当前配置
let ui = {
title: "参数设置",
width: device.width,
height: device.height,
views: [
{
type: "view",
layout: "vertical",
width: "match",
height: "match",
padding: 15,
children: [
// 滚动设置
{
type: "text",
text: "滚动设置",
size: 16,
marginBottom: 10,
bold: true
},
{
type: "input",
hint: "每次滚动次数",
text: config.scrollCount.toString(),
id: "scroll_count",
inputType: "number",
marginBottom: 10
},
{
type: "input",
hint: "滚动间隔(毫秒)",
text: config.scrollDelay.toString(),
id: "scroll_delay",
inputType: "number",
marginBottom: 15
},
// 阅读设置
{
type: "text",
text: "阅读设置",
size: 16,
marginBottom: 10,
bold: true
},
{
type: "input",
hint: "单篇阅读时长(毫秒)",
text: config.readTime.toString(),
id: "read_time",
inputType: "number",
marginBottom: 15
},
// 运行设置
{
type: "text",
text: "运行设置",
size: 16,
marginBottom: 10,
bold: true
},
{
type: "input",
hint: "最大运行时长(毫秒)",
text: config.maxRunTime.toString(),
id: "max_runtime",
inputType: "number",
marginBottom: 15
},
// 保存按钮
{
type: "button",
text: "保存设置",
id: "save_config",
width: "match",
height: 50,
bg: "#07C160",
color: "#ffffff"
}
]
}
]
};
return ui;
}
// 更新UI日志
function updateLog(text) {
ui.run(() => {
let log = ui.log_content.getText();
let time = new Date().toLocaleTimeString();
ui.log_content.setText(time + ": " + text + "\n" + log);
});
}
// 初始化UI事件
function initUIEvents() {
ui.start_btn.click(() => {
updateLog("开始执行养号任务");
threads.start(main);
});
ui.stop_btn.click(() => {
updateLog("手动停止任务");
exit();
});
ui.config_btn.click(() => {
let configUI = createConfigUI();
dialogs.build(configUI).show();
// 保存配置事件
ui.save_config.click(() => {
let newConfig = {
scrollCount: parseInt(ui.scroll_count.getText()),
scrollDelay: parseInt(ui.scroll_delay.getText()),
readTime: parseInt(ui.read_time.getText()),
maxRunTime: parseInt(ui.max_runtime.getText())
};
files.write("config.json", JSON.stringify(newConfig));
updateLog("配置已保存");
dialogs.dismiss();
});
});
}
// 启动UI
let ui = dialogs.build(createMainUI()).show();
initUIEvents();
updateLog("UI初始化完成");
控制器部分:
public class BLLService
{
private readonly DALContext _db;
public BLLService(DALContext db)
{
_db = db;
}
public List<StudentModel> GetAllStudents()
{
return _db.Students.ToList();
}
public int BatchAddStudents(List<StudentModel> students)
{
_db.Students.AddRange(students);
return _db.SaveChanges();
}
public int BatchDelete(string[] ids)
{
var toDelete = _db.Students.Where(s => ids.Contains(s.StudentId));
_db.Students.RemoveRange(toDelete);
return _db.SaveChanges();
}
public int BatchUpdate(List<StudentModel> students)
{
_db.Students.UpdateRange(students);
return _db.SaveChanges();
}
}
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。