This repository has been archived by the owner on Sep 3, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.js
115 lines (110 loc) · 3.77 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
let { start_app, click_item, has_text, wait_for, swipe_down, swipe_up, set_runing_tip, get_date, get_month } = require('autojs_sdk.js');
// 检查脚本是否重复运行
engines.all().slice(1).forEach(script => {
if (script.getSource().getName().indexOf(engines.myEngine().getSource())) {
toastLog('脚本正在运行中');
engines.myEngine().forceStop();
}
});
const getToday = (sep) => {
if (!sep) sep = '-';
const d = new Date();
return [d.getFullYear(),(d.getMonth()+1).toString().padStart(2,'0'), (d.getDate()).toString().padStart(2,'0')].join(sep);
};
const storage = storages.create('wjx');
let myname = storage.get('name');
if (!myname) {
myname = dialogs.prompt('请输入孩子的真实姓名', '');
if (myname.length>0) storage.put('name', myname);
}
const ctt = random(358,368) / 10 ;
console.log(myname, ctt);
const capimg = files.cwd() + '/temp/screencapture.' + getToday() + '.png';
files.ensureDir(capimg);
console.log(capimg);
if (files.exists(capimg)) {
toastLog('今天已经上传了');
sleep(5000);
// exit();
}
const cle = (e) => {
let eb = e.bounds();
click(eb.centerX(),eb.centerY());
};
const swipe_to_click = function(text, upward) {
while (!has_text(text)){
if (upward) swipe_down();
else swipe_up();
}
click_item(text);
};
let main = function(){
sleep(3000);
id('cns').text('微信').findOne().parent().parent().click();
swipe_down();
sleep(2000);
depth(22).className('android.widget.TextView').text('随申办').findOne().parent().click();
className('android.view.View').text('随申码').findOne().click()
className('android.view.View').text('亲属随申码').findOne().click()
className('android.view.View').text(myname + '的随申码').waitFor()
let e = text('查看').findOnce( 0 + 1 );
cle(e);
className('android.view.View').text('绿色').depth(22).waitFor();
set_runing_tip('');
sleep(1000);
captureScreen(capimg);
sleep(100);
start_app(lmain, '微信', '把截图上传到问卷星', false, true);
};
let main_bak = function(){
sleep(3000);
id('cns').text('我').findOne().parent().parent().click();
click_item('支付');
click_item('随申码');
click_item('防疫健康码');
click_item('查看防疫健康码');
click_item('亲属随申码');
wait_for(myname + '的随申码');
let e = text('查看').findOnce( 0 + 1 );
cle(e);
wait_for('绿色');
set_runing_tip('');
sleep(1000);
captureScreen(capimg);
sleep(100);
start_app(subaction, '微信', '把截图上传到问卷星', false, true);
};
let lmain = function(){
sleep(2000);
id('cns').text('我').findOne().parent().parent().click();
sleep(1000);
let sc = className('android.widget.TextView').text('收藏').depth(20).findOne();
cle(sc);
swipe_to_click('政海幼儿园幼儿每日健康随申码收集表');
sleep(7*1000);
click_item('请选择日期',[250,125]);
wait_for('确定');
click_item('确定');
input(1,myname);
input(2,ctt);
if (get_month()==7 && get_date()<25) {
swipe_to_click('其他');
input(3,'吉林省蛟河市');
}else{
swipe_to_click('上海');
}
click_item('选择文件');
click_item('文件管理');
click_item('脚本');
click_item('随申码上传问卷星');
click_item('temp');
if (!has_text(files.getName(capimg))){
toastLog('没找到截图!');
exit();
}
click_item(files.getName(capimg));
click_item('确定');
wait_for('上传成功');
swipe_to_click('提交');
};
start_app(main, '微信', '查找' + myname + '的随申码并截图', false, true);