-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.js
118 lines (113 loc) · 4.3 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/*
* 基于autojs,微信全自动发送消息脚本,支持包括锁屏密码和应用锁等图案解锁进入。
* by Runze Lee
*/
//全局常量
const NAME = "文件传输助手"; //发送给谁(如果备注过就是备注名)
const MSG = "求英语作业物资"; //发送的内容
const HASPWD = true; //手机有没有图案锁屏密码
const PWD = p => { //图案锁屏密码(从左到右从上到下每个点记为一个1-9的数字,第一个参数是总滑动时间,如果密码长时间短会来不及绘全)
gesture(1500, p[1], p[4], p[5], p[2], p[3], p[6], p[9], p[8], p[7]);
};
const PWD_POSITION = Array(null, //锁屏密码的每个图案点坐标,可以通过开发者选项里的指针位置获取
[145, 852], [360, 852], [570, 852],
[145, 1060], [360, 1060], [570, 1060],
[145, 1268], [360, 1268], [570, 1268]
);
const HASAPPLOCK = false; //微信有没有图案应用锁
const APPLOCK = p => { //图案应用锁密码
gesture(1500, p[1], p[4], p[5], p[2], p[3], p[6], p[9], p[8], p[7]);
};
const APPLOCK_POSITION = Array(null, //应用锁的每个图案点坐标
[145, 852], [360, 852], [570, 852],
[145, 1060], [360, 1060], [570, 1060],
[145, 1268], [360, 1268], [570, 1268]
);
const DEBUG = true; //启用则不发送消息,只到达消息框输入消息
if (!device.isScreenOn()) {
if (HASPWD){
unlock(true, false);
}else{
unlock(false, false);
}
sleep(1000);
}
toast("脚本开始运行,若你正在使用手机,请等待脚本执行完毕");
var launchtime = 0;
while (!id("fly").exists()) {
if (currentActivity().includes("com.tencent.mm")) {
var backtime = 0;
while (!id("fly").exists()) {
if(currentActivity().match("com.tencent.mm.app.WeChatSplashActivity")){
id("fly").waitFor();//在地球小人页面等待进入主页
break;
}
backtime++;
back();//在微信的其他activity返回到首页
sleep(500);
if (backtime > 10) {
toast("第" + backtime + "次返回,返回次数过多,若未进入微信请重新运行脚本😱");
}
}
break;
}
launchtime++;
app.startActivity({
action: "android.intent.action.MAIN",
className: "com.tencent.mm.ui.LauncherUI",
packageName: "com.tencent.mm"
});
toast("正在打开微信");
sleep(3000);
if (HASAPPLOCK && text("请输入密码").exists()) {
unlock(true, true);
sleep(500);
if (id("fly").exists()) {
break;
}
}
if (launchtime > 5) home();//启动不太可能超过15秒,一般返回了假的activity,回桌面重进
if (launchtime > 10) {
toast("第" + launchtime + "次开启,开启次数过多,若已经进入微信请重新运行脚本😱");
}
}
var main = id("ki2").className("android.widget.RelativeLayout").drawingOrder(1).findOne().bounds();
click(main.centerX(), main.centerY());
sleep(500);
findZztAndSend(NAME, MSG);
function unlock(hasLock, isAppLock) {
if (!isAppLock) {
device.wakeUp();
sleep(500);
swipe(500, 2000, 500, 1000, 210);
sleep(500);
if(hasLock) PWD(PWD_POSITION);
} else {
if(hasLock) APPLOCK(APPLOCK_POSITION);
}
}
function findZztAndSend(zzt_name, msg) {
var zzt = id("hje").className("android.view.View").text(zzt_name);
var toTop = id("fy").findOne();
//双击左上角置顶,然后循环向下翻找人
click(toTop.bounds().centerX(), toTop.bounds().centerY());
click(toTop.bounds().centerX(), toTop.bounds().centerY());
var scrolltime = 0;
while (!zzt.exists() || zzt.findOne().bounds().top > id("fly").findOne().bounds().top) {
scrolltime++;
swipe(500, 1000, 500, 20, 200);
sleep(500);
if (scrolltime > 10) {
toast("第" + scrolltime + "次滑动,滑动次数过多,若在底部反复横跳,请重新运行脚本😱");
}
}
click(zzt.findOne().bounds().centerX(), zzt.findOne().bounds().centerY());
sleep(1000);
className("EditText").findOne().setText(msg);
if (!DEBUG) {
text("发送").findOne().click();
toast("已发送,脚本执行完毕");
} else {
toast("调试模式,已输入消息");
}
}