实践|小黑盒的签到autojs脚本

介绍

三个任务,分享、点赞、转发都写了,基于无障碍做的,不需要截图权限。项目地址还是autojs脚本的地址(见github)

代码

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
// 小嘿盒
let msg = id("iv_home_msg").findOnce;

console.show();//Set console
// 设备信息
var WIDTH = device.width,
HEIGHT = device.height,
TYPE = device.brand + ' ' + device.model;

console.clear;

log('\n分辨率:', WIDTH, '*', HEIGHT);

let StartServer = true;// 判断服务是否开启

while (StartServer) {
if (!id("iv_home_msg").findOnce()) {
log("不在小嘿盒主页,请手动打开");
// 不在小黑盒主页跳过
sleep(1000);// 等待1s
continue;
}
else {
let title = className("androidx.recyclerview.widget.RecyclerView").findOne();
// 执行share任务
log("执行share任务...");
let i = 1;



try {
Tv = title.child(i);
Tv.click();
}
catch (error) {
sleep(1000);
}
sleep(500);
log("准备分享");
// 稍微判断一手
while (!id("iv_appbar_action_button").findOne()) {
log("没找到");
continue;
}
let b = id("button_right").findOne().bounds();
let count_tmp = 0;
while (!text("微信好友").findOnce()) {
click(b.centerX(), b.centerY());//再点一次
if (count_tmp++ > 500) {
log("share error");
break;
}
sleep(500);
if (count_tmp >= 1) log("click another!");
}
sleep(2500);
text("微信好友").findOne().parent().click();
sleep(1500);

while (!back()) {
continue;
}
log("分享成功");
sleep(1500);
while (!back()) {
continue;
}
sleep(1000);



// 执行点赞任务
log("执行点赞任务");
for (; i < 5; i++) {
try {
Tv = title.child(i);
Tv.click();
}
catch (error) {
sleep(1000);
}
sleep(1500);
//log("准备点赞");
//let d = id("img").findOne().bounds();
//click(d.centerX(), d.centerY());
click(0.8157 * WIDTH, 0.9653 * HEIGHT);
log("点赞数:", i);
sleep(1500);
while (!back()) {
continue;
}
sleep(1500);
//title.scrollUp();
// 滑动
swipe(WIDTH / 2, HEIGHT / 2, WIDTH / 2, HEIGHT / 2 - 250, 200);
}
log("还有个小bug,只能点四个赞~~~~~还有一个就得自己点了~~~");
}
log("结束");
break;
}