autojs,读取一行删除一行,停止自己外的脚本
时间:2022-08-27 12:00:00
新建交流群917400262
欢迎加入v群,与大神交流
免责声明:本博客提供的所有内容仅供学习、分享和交流,我们不保证内容的正确性。使用本博客内容的问题与本博客无关。使用本博客代码时,您已接受本博客的免责声明
正文部分
目录
读取一行删除一行
function read_delete() { //删除第一行 var path = "/sdcard/gjc.txt";//txt文本路径 var reg = /^\s |s $/g; //匹配无效空白行 var txt = files.read(path).replace(reg, "").split("\n"); let ret_text = txt[0]; log(ret_text.length); if (txt != "") { txt.splice(0, 1); //删除 files.write(path, txt.join("\n")); if (ret_text.length > 0) { return ret_text.trim(); }; } else { return "衣服" }; file.close(); };
两种方法(获取当前屏幕文本)
console.show(); className("TextView").find().forEach(function(tv){ if(tv.text() != ""){ log(tv.text()); } });
方法2
console.show(); className("TextView").find().forEach(function(tv){ if(tv.text() != ""){ log(tv.text()); } });
点击函数
function Click(node) { //九黎超级节点击函数,qq1906507927.的问题 try { if (node) { if (node.click()) { return true } else if (node.parent().click()) { return true } else if (node.parent().parent().click()) { return true } else if (node.parent().parent().parent().click()) { return true } else if (node.parent().parent().parent().parent().click()) { return true } else if (node.parent().parent().parent().parent().parent().click()) { return true } else if (node.parent().parent().parent().parent().parent().parent().click()) { return true } } } catch (e) { } return false }
判断软件是否已安装
if (app.getPackageName("QQ")) { log("已安装") }else{ log("未安装") }
停止你以外的所有脚本
engines.all().map((ScriptEngine) => { if (engines.myEngine().toString() !== ScriptEngine.toString()) { ScriptEngine.forceStop(); } });
数据读取保存删除
//保存本地数据 function setStorageData(name, key, value) { const storage = storages.create(name); storage.put(key, value); }; ///读取本地数据 function getStorageData(name, key) { const storage = storages.create(name); if (storage.contains(key)) { return storage.get(key, ""); }; ///默认返回undefined }; ///删除本地数据 function delStorageData(name, key) { const storage = storages.create(name); if (storage.contains(key)) { storage.remove(key); }; };
获取剪贴板的内容
function 剪切板内容() { let l = false ui.run(() => { var w = floaty.rawWindow( '\ < img src="@drawable/ic_description_black_48dp"h="20" />\ ' ); w.setTouchable(false); w.requestFocus(); let 定时器 = setInterval(() => { if (l) { log("剪切板内容:" getClip()) w.close(); clearInterval(定时器); } }, 1) }) let str = getClip() l = true return str }
实用的替换replace代码
var 答案2="答案如下..." var 答案= 答案2.replace("答案如下",""); ///用空替换答案,选择实战项目,进行数据脱敏
其他小tip:
在线程中使用ui函数操作时需要使用ui.run,否则会报错4.免费版本可以适应大多数机器,而无需此,但云机不支持它
声明
本教程仅用于学习, 禁止用于其他用途
QQ群
917400262