热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

Autojs自动化实现自动删除公众号文章(通过订阅号助手删除)

设备小米9效果autojs1autojs2代码UIui;conststoragestorages.create(dinyue);auto()varsearch_v

设备

小米9


效果


autojs1


 


autojs2



代码

UI


"ui";
const storage = storages.create("dinyue");
auto()var search_value = ''if(storage.contains('search_value')){search_value = storage.get('search_value')
}ui.layout(输入要匹配的关键字
);//创建新的线程
threads.start(function () {createFloaty();
});/*** 设置悬浮窗*/
function createFloaty() {// const Utils = require('lib')window = floaty.window({/* */});window1 = floaty.rawWindow();window.exitOnClose();window.setSize(200, 400);window.setPosition(device.width - 1080, device.height/10);window1.exitOnClose();window1.setTouchable(false);window1.setSize(device.width, device.height / 4);window1.setPosition(0, device.height - device.height / 4);//点击返回// window.return.click(() => {// app.launch("com.xm.duihua");// engines.myEngine().forceStop();// });//点击停止window.stop.click(() => {// if (thread) {// thread.interrupt();// }// window1.status.setText("已停止");engines.stopAll()});//点击开始window.start.click(() => {window1.status.setText("正在运行");thread = threads.start(function () {let search_val = ui.search.text()if(search_val.trim().length==0){toast('请填写要匹配的关键字')}else{storage.put('search_value',search_val)engines.execScriptFile("./sub.js",{delay:2000});}});});}

sub.js

const Utils = require('lib');
const storage = storages.create("dinyue");
// 编写主函数:程序启动后执行的逻辑代码。
function main() {sleep(2000)let search =storage.get('search_value')while(!Utils.wait_for_num('互动',1)){back()}sleep(2000)click(535, 2120)sleep(2000)click(945, 1065)sleep(2000)Utils.click_item('已发表内容',[700,0])setText(search)click(995, 1510)sleep(2000)// sleep(3000)// Utils.click_item('【宁大晚安】')while(true){let items = textContains(search).find()if(items.empty()){Utils.swipe_up()}else{for(let index=1;index}// 启动应用:传入参数依次为:主函数,要启动的 App 名称,当前应用描述,是否语音播报执行状态。
Utils.start_app(main, '订阅号助手', '订阅号助手', false,false)

 lib.js

/*** 仓库:https://github.com/kangour/autojs_sdk*/operation_app = ''
window = {width: device.width,height: device.height,
}/*** 权限管理*/
auto.waitFor();
setScreenMetrics(window.width, window.height);
if (!requestScreenCapture()) {log('Screen capture fail');exit();
}/*** 通知栏提示*/
let runing_tip = floaty.rawWindow(
)
runing_tip.setPosition(220, 5);
runing_tip.setTouchable(false);/*** 通知栏提示内容设置* @param {*} _text 提示文本*/
function set_runing_tip(_text) {ui.run(function () {runing_tip.text.setText(operation_app + _text);});
}/*** 修改通知栏提示的坐标* @param {*} _text 提示文本*/
function set_runing_tip_position(x, y) {runing_tip.setPosition(x, y);
}/*** 开始结束提示*/
function start_tip(this_app) {warn('开始执行', this_app)vibrate(100)
}
function end_tip(operation_app) {warn(operation_app, '执行完成')vibrate(300)
}
// 普通上滑解锁
// /**
// * 解锁
// */
// function unlock() {
// while (true) {
// // 唤醒屏幕
// if (!device.isScreenOn()) {
// log('Wake up')
// device.wakeUp();
// // 避开锁屏界面的弹窗
// back()
// }
// if (has_text('画报')) {
// warn('尝试解锁')
// swipe(500, 1600, 100, 500, 200);
// sleep(500)
// } else {
// warn('解锁成功')
// break
// }
// }
// log('Unlocked')
// sleep(800);
// back() // 避开解锁后界面的弹窗
// sleep(800)
// }// MUI10 解锁
function unlock() {// 唤醒屏幕if (!device.isScreenOn()) {log('Wake up')device.wakeUp();// 避开锁屏界面的弹窗back()}sleep(800)if (has_text('画报')) {warn('尝试解锁')//下拉状态栏swipe(500, 30, 500, 1000, 300);sleep(400);//点击时间click(100, 120);sleep(400);//解锁 密码 desc(2).findOne().click();desc(3).findOne().click();desc(6).findOne().click();desc(9).findOne().click();//等待解锁完成text('闹钟').waitFor();warn('Unlocked')//返回主页home();}
}/*** 获取文本类型,分别有 text、desc* @param {string} _text 需要查询的文本*/
function get_text_type(_text) {for (i = 5; i > 0; i--) {if (textContains(_text).exists()) {return 'text'} else if (descContains(_text).exists()) {return 'desc'} else {// verbose(_text, '不存在 ' + i)sleep(200)}}return null
}/*** 当前屏幕是否存在文本* @param {*} _text 需要查询的文本*/
function has_text(_text) {set_runing_tip('find ' + _text)point = get_coord_by_text(_text, 'no_tip')if (point != null && point.x > 0 && point.x 0 && point.y }/*** 设备音量* @param {*} number */
function set_volume(number) {device.setMusicVolume(device.getMusicMaxVolume() / 100 * number)
}/*** 震动控制* @param {*} duration 震动时长* @param {*} times 震动次数* @param {*} delay 两次间的延迟*/
function vibrate(duration, times, delay) {if (delay == null) delay = 0if (times == null) times = 1for (i = 0; i }/*** 操作失败后的提示弹窗,引导下一步操作* @param {*} callback 弹窗确认后执行的函数,一般出入执行失败的函数* @param {*} _text */
function confirm_continue(callback, _text) {tts_report(_text &#43; &#39;失败&#39;)if (get_hours() <9) {sleep(2000)callback(_text)return}vibrate(1000, 3, 0)if (confirm(_text &#43; "不存在&#xff0c;2s 后重试&#xff1f;")) {toast(&#39;2s 后重试&#39;)sleep(2000)callback(_text)} else {if (confirm("继续下一步&#xff1f;")) {toast(&#39;2s 后继续&#39;)sleep(2000)} else {toastLog(&#39;手动结束运行&#39;)exit()}}
}/*** 文本点击* &#64;param {*} _text 待查询的文本* &#64;param {*} fix_coord 修复坐标位置&#xff0c;传入一个数组&#xff0c;第一位是 x 坐标&#xff0c;第二位是 y 坐标。* 应用中的页面结构决定了获取的坐标准确性&#xff0c;调试时&#xff0c;可以用开发者工具打开指针位置&#xff0c;查看点击位置是否正确&#xff0c;错误的点击位置则需要传入修复的坐标。* 例如&#xff1a;[10, -10] 表示在点击时&#xff0c;x 右移 10 个点&#xff0c;y 上移 10 个点* &#64;param {*} tip_type 未找到时&#xff0c;是否需要提示&#xff0c;传入 no_tip 则不提示*/
function click_item(_text, fix_coord, tip_type) {if (fix_coord &#61;&#61; undefined) fix_coord &#61; [0, 0]wait_for(_text)log(&#39;(click) &#39; &#43; _text)if (has_text(_text) &#61;&#61; false && tip_type !&#61; &#39;no_tip&#39;) {confirm_continue(click_item, _text)return}text_type &#61; get_text_type(_text)if (text_type &#61;&#61; &#39;text&#39;) {click_text(_text, fix_coord)} else if (text_type &#61;&#61; &#39;desc&#39;) {click_desc(_text, fix_coord)} else if (tip_type !&#61; &#39;no_tip&#39;) {error(&#39;Unknown type&#39;, text_type)}
}/*** 任意类型的文本循环点击* &#64;param {*} _text 待查询的文本* &#64;param {*} tip_type 未找到时&#xff0c;是否需要提示&#xff0c;传入 no_tip 则不提示*/
function click_item_each(_text, tip_type) {wait_for(_text)log(&#39;(click-each) &#39; &#43; _text)if (has_text(_text) &#61;&#61; false && tip_type !&#61; &#39;no_tip&#39;) {confirm_continue(click_item, _text)return}text_type &#61; get_text_type(_text)if (text_type &#61;&#61; &#39;text&#39;) {click_text_each(_text)} else if (text_type &#61;&#61; &#39;desc&#39;) {click_desc_each(_text)} else if (tip_type !&#61; &#39;no_tip&#39;) {error(&#39;Unknown type&#39;, text_type)}
}/*** 获取文本坐标&#xff0c;文本点击时自动调用* &#64;param {*} _text 待查询的文本* &#64;param {*} tip_type 未找到时&#xff0c;是否需要提示&#xff0c;传入 no_tip 则不提示*/
function get_coord_by_text(_text, tip_type) {text_type &#61; get_text_type(_text)btn &#61; nullif (text_type &#61;&#61; null) {if (tip_type !&#61; &#39;no_tip&#39;) confirm_continue(get_coord_by_text, _text)return null} else if (text_type &#61;&#61; &#39;text&#39;) {btn &#61; textContains(_text).findOne()if (btn.bounds().centerX() &#61;&#61; undefined) btn &#61; textStartsWith(_text).findOne()if (btn.bounds().centerX() &#61;&#61; undefined) btn &#61; textEndsWith(_text).findOne()} else if (text_type &#61;&#61; &#39;desc&#39;) {btn &#61; descContains(_text).findOne()if (btn.bounds().centerX() &#61;&#61; undefined) btn &#61; descStartsWith(_text).findOne()if (btn.bounds().centerX() &#61;&#61; undefined) btn &#61; descEndsWith(_text).findOne()} else {if (tip_type !&#61; &#39;no_tip&#39;) error(&#39;Unknown type&#39;, text_type)return null}point &#61; btn.bounds()if (point.centerX()) {return {x: point.centerX(),y: point.centerY()}} else {sleep(800)return get_coord_by_text(_text, tip_type)}
}function click_desc(_text, fix_coord) {point &#61; get_coord_by_text(_text)click(point.x &#43; fix_coord[0], point.y &#43; 10 &#43; fix_coord[1]);sleep(800)
}function long_click_desc(_text) {point &#61; get_coord_by_text(_text)log(&#39;(long-click)&#39; &#43; _text)press(point.x, point.y &#43; 10, 800)sleep(500)
}function click_desc_each(_text) {let btns &#61; descContains(_text).untilFind();btns.each(function (btn) {let point &#61; btn.bounds();click(point.centerX(), point.centerY() &#43; 10);})sleep(800)
}function click_text(_text, fix_coord) {btn &#61; textContains(_text).findOne()let point &#61; btn.bounds();click(point.centerX() &#43; fix_coord[0], point.centerY() &#43; 10 &#43; fix_coord[1]);sleep(800)
}
function click_text_each(_text) {let btns &#61; textContains(_text).untilFind();btns.each(function (btn) {let point &#61; btn.bounds();click(point.centerX(), point.centerY() &#43; 10);})sleep(800)
}function has_color(_color, x, y, w, h) {return find_color(_color, x, y, w, h)
}function find_color(_color, x, y, w, h) {if (x &#61;&#61; undefined) {x &#61; 0y &#61; 0w &#61; device.widthh &#61; device.height}image &#61; captureScreen();let point &#61; findColorInRegion(image, _color, x, y, w, h);if (point) return pointelse {sleep(200)return null}
}
/*** 根据id判断 是否有这个组件* &#64;param {} id * &#64;returns */
function has_id(id_){return id(id_).exists()
}/*** 等待某区域颜色出现&#xff0c;持续 10s* &#64;param {*} _color * &#64;param {*} x * &#64;param {*} y * &#64;param {*} w * &#64;param {*} h */
function wait_for_color(_color, x, y, w, h) {let n &#61; 0while (true) {log(&#39;wait_for_color&#39;, _color)verbose(&#39;(find-color)&#39; &#43; _color)point &#61; find_color(_color, x, y, w, h)if (point) return pointelse {sleep(1000)n&#43;&#43;}if (n > 10) {warn(&#39;not found&#39;, _color)return null}}
}/*** 通过颜色获取坐标* &#64;param {*} _color * &#64;param {*} x * &#64;param {*} y * &#64;param {*} w * &#64;param {*} h */
function get_coord_by_color(_color, x, y, w, h) {verbose(&#39;(find-color)&#39; &#43; _color)return wait_for_color(_color, x, y, w, h)
}/*** 0 到 200 s 随机睡眠* &#64;param {*} tip_message 睡眠时的提示消息*/
function random_sleep(tip_message) {if (tip_message &#61;&#61; undefined) tip_message &#61; &#39;random-sleep&#39;random_number &#61; random(0, 200)log(tip_message &#43; &#39; sleep &#39; &#43; random_number &#43; &#39; s&#39;)for (i &#61; random_number; i >&#61; 0; i--) {if (i % 3 &#61;&#61; 0) toast(tip_message &#43; &#39; &#39; &#43; i &#43; &#39; s&#39;)sleep(1000)}
}/*** 按键监听&#xff0c;自动执行&#xff0c;按下音量加结束进程*/
function key_event() {threads.start(function () {events.observeKey();events.on("key_down", function (keyCode, events) {if (keyCode &#61;&#61; keys.volume_up) {toastLog(&#39;运行结束&#39;)exit();}});});
}// /**
// * 普通左右布局任务
// * 将即将启动的 App 从最近任务中移除
// * &#64;param {*} operation_app App 名称
// */
// function clear_recent(operation_app) {
// log(&#39;移除最近任务&#39;)
// home()
// sleep(800)
// recents()
// sleep(800)
// let times_swips &#61; 0
// while (true) {
// if (has_text(operation_app)) {
// point &#61; get_coord_by_text(operation_app)
// if (point.x <530) {
// swipe(100, 1000, 500, 1000, 500);
// } else if (point.x > 800) {
// swipe(500, 1000, 100, 1000, 500);
// } else {
// swipe(point.x - 330, 1400, point.x - 330, 100, 1000);
// sleep(500)
// }
// times_swips&#43;&#43;
// if (times_swips > 10) {
// warn(&#39;重试&#39;)
// times_swips &#61; 0
// clear_recent()
// break
// }
// } else {
// break
// }
// }
// home()
// }/*** Mui10 任务* 将即将启动的 App 从最近任务中移除* &#64;param {*} operation_app App 名称*/
function clear_recent(operation_app) {log(&#39;移除最近任务&#39;)home()sleep(800)recents()sleep(800)let times_swips &#61; 0while (true) {if (has_text(operation_app)) {point &#61; get_coord_by_text(operation_app)swipe(point.x, point.y, point.x &#43; 500, point.y, 600);sleep(800)times_swips&#43;&#43;if (times_swips > 10) {warn(&#39;重试&#39;)times_swips &#61; 0clear_recent()break}} else {break}}home()
}
/*** 脚本运行的前置&#43;后置自动化操作&#xff0c;包括屏幕解锁&#xff0c;自动按键监听&#xff0c;移出最近任务&#xff0c;启动 App&#xff0c;执行脚本&#xff0c;结束进程等。* &#64;param {*} callback 启动 App 后需要执行的内容* &#64;param {*} op_app 需要启动的 App&#xff0c;如&#xff1a;网易云音乐* &#64;param {*} this_app 当前脚本描述&#xff0c;如&#xff1a;播放日推* &#64;param {*} use_tts 是否使用结束语音&#xff0c;传入 true 时&#xff0c;会在运行结束前给出语音提示*/
function start_app(callback, op_app, this_app, use_tts, close_app) {if (close_app &#61;&#61; undefined) close_app &#61; falsethis_app &#61; this_app !&#61; undefined ? this_app : op_appoperation_app &#61; op_app &#43; &#39;\n&#39;while (!device.isScreenOn()) {unlock();}key_event()sleep(800)if (close_app &#61;&#61; true) clear_recent(op_app)log(&#39;Launch&#39;, op_app)launchApp(op_app);start_tip(this_app);sleep(1000)if (op_app) {callback();end_tip(this_app);if (use_tts) tts_report(this_app &#43; &#39;成功&#39;)exit()}
}/*** 给出语音提示* &#64;param {*} _text */
function tts_report(_text) {warn(_text)importClass(java.io.File);importClass(android.speech.tts.TextToSpeech);let ttsStatus &#61; false;let ttsListener &#61; new TextToSpeech.OnInitListener({onInit: function (status) {if (status &#61;&#61; TextToSpeech.SUCCESS) {let ttsSetLanguageResult &#61; TTS.setLanguage(TTS.getDefaultVoice().getLocale()/*ttsLanguage*/);if (ttsSetLanguageResult !&#61; TextToSpeech.LANG_MISSING_DATA && ttsSetLanguageResult !&#61; TextToSpeech.LANG_NOT_SUPPORTED) {ttsStatus &#61; true;TTS.stop();speech(_text);// let file &#61; "/sdcard/xxx.mp3";// speech(_text, file);} else {toast("TTS不支持当前语言");}} else {toast("初始化TTS失败");}}})let TTS &#61; new TextToSpeech(context, ttsListener);function speech(ttsText, fileName) {if (TTS && ttsStatus) {if (ttsText.length <&#61; TextToSpeech.getMaxSpeechInputLength()) {if (fileName) {let file &#61; new File(fileName);if (!file.exists()) {file.createNewFile();}TTS.synthesizeToFile(ttsText, null, file, Math.random());} else {TTS.speak(ttsText, TextToSpeech.QUEUE_FLUSH/*QUEUE_FLUSH插队&#xff0c;QUEUE_ADD排队*/, null);}return true;} else {toast("朗读文本过长");return false;}} else {toast("TTS未准备好");return false;}}
}/*** 颜色点击* &#64;param {*} _color 需要点击的颜色* &#64;param {*} x 颜色区域的左上角 x 坐标* &#64;param {*} y 颜色区域的左上角 y 坐标* &#64;param {*} w 颜色区域的宽度* &#64;param {*} h 颜色区域的高度*/
function click_color(_color, x, y, w, h) {let point &#61; get_coord_by_color(_color, x, y, w, h)if (point) {click(point.x, point.y &#43; 20);return true}return false
}/*** 颜色循环点击* &#64;param {*} _color 需要点击的颜色* &#64;param {*} x 颜色区域的左上角 x 坐标* &#64;param {*} y 颜色区域的左上角 y 坐标* &#64;param {*} w 颜色区域的宽度* &#64;param {*} h 颜色区域的高度*/
function click_color_each(_color, x, y, w, h) {let attempts &#61; 0let finded &#61; 0while (true) {if (click_color(_color, x, y, w, h)) {finded&#43;&#43;if (finded > 10) return} else {attempts&#43;&#43;if (attempts > 2) return}sleep(300)}
}/*** 等待文本出现* &#64;param {*} _text 等待出现的文本*/
function wait_for(_text) {log(&#39;(wait)&#39; &#43; _text)let n &#61; 0while (true) {n&#43;&#43;if (has_text(_text)) {set_runing_tip(&#39;&#39;)return true} else {set_runing_tip(&#39;查找(&#39; &#43; _text &#43; &#39;)第&#39; &#43; n &#43; &#39;次&#39;)}sleep(1500)}
}/*** 等待文本出现 到达某次 跳出循环 默认 20次* &#64;param {*} _text * &#64;param {*} num * &#64;returns */
function wait_for_num(_text,num) {log(&#39;(wait)&#39; &#43; _text)if (num &#61;&#61; undefined) num &#61; 20let n &#61; 0while (true) {n&#43;&#43;if (has_text(_text)) {set_runing_tip(&#39;&#39;)return true} else {set_runing_tip(&#39;查找(&#39; &#43; _text &#43; &#39;)第&#39; &#43; n &#43; &#39;次&#39;)if(n>num){return false}}sleep(1500)}
}/*** 接口描述&#xff1a;等待某文本出现之前的点击。* 场景举例&#xff1a;启动网易云音乐时&#xff0c;等待首页出现之前&#xff0c;点击跳过按钮 wait_befor_click(&#39;我的&#39;, &#39;跳过&#39;)* &#64;param {*} wait_text 等待出现的文本* &#64;param {*} click_text 需要点击的文本* &#64;param {*} timer 等待计时器&#xff0c;计时器越长&#xff0c;click_text 被点击的几率越高*/
function wait_befor_click(wait_text, click_text, timer) {log(&#39;(wait-click)&#39; &#43; click_text)if (timer &#61;&#61; undefined) timer &#61; 10for (let n &#61; timer; n > 0; n--) {if (has_text(wait_text)) {break} else if (has_text(click_text)) {click_item(click_text)} else sleep(600)}// wait_for(wait_text)return
}/*** 获取当前年月日时分秒和星期*/
function get_year() {let now &#61; new Date();return now.getFullYear();
}
function get_month() {let now &#61; new Date();return now.getMonth() &#43; 1;
}
/*** 获取上个月月份*/
function get_last_month() {_month &#61; get_month()if (_month > 1 && _month <&#61; 12) return _month - 1else if (_month &#61;&#61; 1) return 12else {error(&#39;月份超出范围&#39;)return false}
}/*** 计算单休的每月工作时长* &#64;param {*} start_date 开始时间&#xff0c;格式&#xff1a;yyyy/mm/dd* &#64;param {*} end_date * &#64;param {*} rest_days 每周休息天数*/
function count_work_day(start_date, end_date, rest_days) {if (rest_days &#61;&#61; undefined) rest_days &#61; 1start_date &#61; string2date(start_date);end_date &#61; string2date(end_date);let delta &#61; (end_date - start_date) / (1000 * 60 * 60 * 24);let weeks &#61; 0;for (i &#61; 0; i }/*** 计算上个月的年份* &#64;param {*} start_date * &#64;param {*} end_date */
function get_last_month_year() {let now &#61; new Date();now &#61; now.valueOf();now -&#61; 20 * 1000 * 60 * 60 * 24;let last_month_date &#61; new Date(now);return last_month_date.getFullYear();
}/*** 返回日期*/
function get_date() {let now &#61; new Date();return now.getDate();
}
/*** 返回星期*/
function get_day() {let now &#61; new Date();return now.getDay();
}
function get_hours() {let now &#61; new Date();return now.getHours();
}
function get_minutes() {let now &#61; new Date();return now.getMinutes();
}
function get_seconds() {let now &#61; new Date();return now.getSeconds();
}/*** 拆分用户设定的时间&#xff0c;20:59:35 分别拆为时分秒* &#64;param {string} _time 时间字符串*/
function get_my_hours(_time) {return Number(_time.split(":")[0])
}
function get_my_minutes(_time) {return Number(_time.split(":")[1])
}
function get_my_seconds(_time) {return Number(_time.split(":")[2])
}/*** 获取倒计时* &#64;param {string} _time 时间字符串*/
function total_seconds_delta(_time) {return ~~(time2date(_time) - new Date()) / 1000
}
function seconds_delta(_time) {let delta_seconds &#61; total_seconds_delta(_time)return parseInt(delta_seconds % 60)
}
function minutes_delta(_time) {let delta_seconds &#61; total_seconds_delta(_time)return parseInt(delta_seconds / 60 % 60)
}
function hours_delta(_time) {let delta_seconds &#61; total_seconds_delta(_time)return parseInt(delta_seconds / 60 / 60 % 60)
}
function time2date(_time) {let str_time &#61; get_year() &#43; &#39;/&#39; &#43; get_month() &#43; &#39;/&#39; &#43; get_date() &#43; &#39; &#39; &#43; _timereturn new Date(str_time)
}
function string2date(_time) {return new Date(_time)
}
function time2str(_time) {let total_seconds &#61; total_seconds_delta(_time)let seconds &#61; seconds_delta(_time)let minutes &#61; minutes_delta(_time)let hours &#61; hours_delta(_time)if (total_seconds <0) {seconds &#43;&#61; 59hours &#43;&#61; 23minutes &#43;&#61; 59}result &#61; &#39;&#39;if (hours !&#61; 0) result &#43;&#61; hours &#43; &#39;h &#39;if (minutes !&#61; 0) result &#43;&#61; minutes &#43; &#39;m &#39;result &#43;&#61; seconds &#43; &#39;s&#39;return result
}/*** 简写的日志输出*/
function error() {res &#61; Array.prototype.slice.call(arguments).join(&#39; &#39;)// toast(res)console.error(res)// if (operation_app !&#61; &#39;&#39;) res &#61; operation_app &#43; resset_runing_tip(res)
}
function warn() {res &#61; Array.prototype.slice.call(arguments).join(&#39; &#39;)toast(res)console.warn(res)// if (operation_app !&#61; &#39;&#39;) res &#61; operation_app &#43; resset_runing_tip(res)
}
function log() {res &#61; Array.prototype.slice.call(arguments).join(&#39; &#39;)console.log(res)// toast(res)// if (operation_app !&#61; &#39;&#39;) res &#61; operation_app &#43; resset_runing_tip(res)
}
function verbose() {res &#61; Array.prototype.slice.call(arguments).join(&#39; &#39;)console.verbose(res)// if (operation_app !&#61; &#39;&#39;) res &#61; operation_app &#43; resset_runing_tip(res)
}/*** 获取问候语*/
function say_hi() {let hour &#61; get_hours()let greet &#61; "Hi"if (hour <&#61; 3) {greet &#61; "晚安"} else if (hour <9) {greet &#61; "早上好"} else if (hour <12) {greet &#61; "上午好"} else if (hour <14) {greet &#61; "中午好"} else if (hour <18) {greet &#61; "下午好"} else if (hour <24) {greet &#61; "晚上好"}return greet
}function click_id(id_name) {id(id_name).findOne().click()
}function swipe_down() {swipe(500, 500, 500, 1500, 500)sleep(800)
}function swipe_up() {swipe(500, 1500, 500, 100, 500)sleep(800)
}/*** 提醒用户&#xff0c;接下来的操作需要注意&#xff08;用户确认后&#xff0c;方可继续&#xff09;* &#64;param {*} _text */
function be_careful(_text) {log(&#39;请注意&#xff0c;&#39;, _text)while (true) {if (confirm(_text)) break;else sleep(1000);}sleep(1000);
}/*** 提醒用户&#xff0c;接下来的操作需要人工处理&#xff08;用户确认后&#xff0c;方可继续&#xff09;* &#64;param {*} _text */
function handwork(_text, timer) {timer &#61; timer &#61;&#61;&#61; undefined ? 2 : timerlet timer_backup &#61; timerlog(&#39;人工&#39;, _text)while (true) {for (timer; timer > 0; timer--) {sleep(1000);toast(&#39;倒计时 &#39; &#43; timer &#43; &#39; s&#39;);}if (confirm(_text &#43; &#39;?&#39;)) break;else timer &#61; timer_backup &#43; 1}
}
/*** 倒计时 秒后执行* &#64;param {}} timer */
function countDown(timer){timer &#61; timer &#61;&#61;&#61; undefined ? 2 : timerfor (timer; timer > 0; timer--) {toast(&#39;倒计时 &#39; &#43; timer &#43; &#39; s 后执行&#39;);sleep(1000);}
}module.exports &#61; {swipe_up: swipe_up,handwork: handwork,be_careful: be_careful,swipe_down: swipe_down,unlock: unlock, // 解锁clear_recent: clear_recent, // 结束最近任务start_app: start_app, // 脚本运行的前置&#43;后置自动化操作&#xff0c;包括屏幕解锁&#xff0c;自动按键监听&#xff0c;移出最近任务&#xff0c;启动 App&#xff0c;执行脚本&#xff0c;结束进程等。wait_for: wait_for, // 等待文本出现wait_for_num:wait_for_num,//等待文本出现 n次has_text: has_text, // 当前屏幕是否存在文本vibrate: vibrate, // 设备震动say_hi: say_hi, // 获取问候语log: log, // 普通日志warn: warn, // 警告日志error: error, // 错误日志verbose: verbose, // 调试日志time2str: time2str, // 时间转字符串time2date: time2date, // 时间转日期random_sleep: random_sleep, // 0 到 200 s 随机睡眠total_seconds_delta: total_seconds_delta, // 获取倒计时click_item: click_item, // 任意类型的文本点击click_color: click_color, // 颜色点击click_id: click_id,find_color: find_color,has_color: has_color,wait_for_color: wait_for_color,click_item_each: click_item_each, // 任意类型的文本循环点击click_color_each: click_color_each, // 颜色循环点击wait_befor_click: wait_befor_click, // 接口描述&#xff1a;等待某文本出现之前的点击。 场景举例&#xff1a;启动网易云音乐时&#xff0c;等待首页出现之前&#xff0c;点击跳过按钮 wait_befor_click(&#39;我的&#39;, &#39;跳过&#39;)get_coord_by_color: get_coord_by_color, // 通过颜色获取坐标get_coord_by_text: get_coord_by_text, // 获取文本坐标&#xff0c;文本点击时自动调用get_last_month: get_last_month, // 获取上个月月份get_year: get_year, // 获取年份get_month: get_month, // 获取月份get_date: get_date, // 返回日期get_day: get_day, // 返回星期get_hours: get_hours, // 返回小时get_minutes: get_minutes, // 返回分钟get_seconds: get_seconds, // 返回秒set_volume: set_volume, // 设置设备音量set_runing_tip: set_runing_tip, // 通知栏提示内容设置key_event: key_event, // 音量加结束脚本string2date: string2date, // 字符串转日期get_last_month_year: get_last_month_year, // 获取上个月的年份count_work_day: count_work_day, // 获取工作天数set_runing_tip_position: set_runing_tip_position, // 设置状态栏位置has_id:has_id,//根据id 判断是否有这个组件countDown:countDown,//倒计时
}

网站

Auto.js Pro Docs


推荐阅读
  • 开发笔记:图像识别基于主成分分析算法实现人脸二维码识别
    篇首语:本文由编程笔记#小编为大家整理,主要介绍了图像识别基于主成分分析算法实现人脸二维码识别相关的知识,希望对你有一定的参考价值。 ... [详细]
  • 1简介本文结合数字信号处理课程和Matlab程序设计课程的相关知识,给出了基于Matlab的音乐播放器的总体设计方案,介绍了播放器主要模块的功能,设计与实现方法.我们将该设 ... [详细]
  • CSS3选择器的使用方法详解,提高Web开发效率和精准度
    本文详细介绍了CSS3新增的选择器方法,包括属性选择器的使用。通过CSS3选择器,可以提高Web开发的效率和精准度,使得查找元素更加方便和快捷。同时,本文还对属性选择器的各种用法进行了详细解释,并给出了相应的代码示例。通过学习本文,读者可以更好地掌握CSS3选择器的使用方法,提升自己的Web开发能力。 ... [详细]
  • CF:3D City Model(小思维)问题解析和代码实现
    本文通过解析CF:3D City Model问题,介绍了问题的背景和要求,并给出了相应的代码实现。该问题涉及到在一个矩形的网格上建造城市的情景,每个网格单元可以作为建筑的基础,建筑由多个立方体叠加而成。文章详细讲解了问题的解决思路,并给出了相应的代码实现供读者参考。 ... [详细]
  • Ihavethefollowingonhtml我在html上有以下内容<html><head><scriptsrc..3003_Tes ... [详细]
  • 带添加按钮的GridView,item的删除事件
    先上图片效果;gridView无数据时显示添加按钮,有数据时,第一格显示添加按钮,后面显示数据:布局文件:addr_manage.xml<?xmlve ... [详细]
  • Sleuth+zipkin链路追踪SpringCloud微服务的解决方案
    在庞大的微服务群中,随着业务扩展,微服务个数增多,系统调用链路复杂化。Sleuth+zipkin是解决SpringCloud微服务定位和追踪的方案。通过TraceId将不同服务调用的日志串联起来,实现请求链路跟踪。通过Feign调用和Request传递TraceId,将整个调用链路的服务日志归组合并,提供定位和追踪的功能。 ... [详细]
  • 今天就跟大家聊聊有关怎么在Android应用中实现一个换肤功能,可能很多人都不太了解,为了让大家更加了解,小编给大家总结了以下内容,希望大家根 ... [详细]
  • 1、PLSQLDeveloper记住登陆密码在使用PLSQLDeveloper时,为了工作方便希望PLSQLDeveloper记住登录Oracle的用户名和密码&#x ... [详细]
  • 涉及的知识点-ViewGroup的测量与布局-View的测量与布局-滑动冲突的处理-VelocityTracker滑动速率跟踪-Scroller实现弹性滑动-屏幕宽高的获取等实现步 ... [详细]
  • Python正则表达式学习记录及常用方法
    本文记录了学习Python正则表达式的过程,介绍了re模块的常用方法re.search,并解释了rawstring的作用。正则表达式是一种方便检查字符串匹配模式的工具,通过本文的学习可以掌握Python中使用正则表达式的基本方法。 ... [详细]
  • springmvc学习笔记(十):控制器业务方法中通过注解实现封装Javabean接收表单提交的数据
    本文介绍了在springmvc学习笔记系列的第十篇中,控制器的业务方法中如何通过注解实现封装Javabean来接收表单提交的数据。同时还讨论了当有多个注册表单且字段完全相同时,如何将其交给同一个控制器处理。 ... [详细]
  • 本文介绍了南邮ctf-web的writeup,包括签到题和md5 collision。在CTF比赛和渗透测试中,可以通过查看源代码、代码注释、页面隐藏元素、超链接和HTTP响应头部来寻找flag或提示信息。利用PHP弱类型,可以发现md5('QNKCDZO')='0e830400451993494058024219903391'和md5('240610708')='0e462097431906509019562988736854'。 ... [详细]
  • Java图形化计算器设计与实现
    本文介绍了使用Java编程语言设计和实现图形化计算器的方法。通过使用swing包和awt包中的组件,作者创建了一个具有按钮监听器和自定义界面尺寸和布局的计算器。文章还分享了在图形化界面设计中的一些心得体会。 ... [详细]
  • SmartRefreshLayout自定义头部刷新和底部加载
    1.添加依赖implementation‘com.scwang.smartrefresh:SmartRefreshLayout:1.0.3’implementation‘com.s ... [详细]
author-avatar
DomincLiu
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有