当前位置:网站首页>autojs,读取一行删除一行,停止自己外的脚本
autojs,读取一行删除一行,停止自己外的脚本
2022-06-11 06:03:00 【九黎AJ】
新建交流群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(
'<vertical>\
< img src="@drawable/ic_description_black_48dp"h="20" />\
</vertical>'
);
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.1免费版可以不用这个也能适配大多数机器,但是云机不支持
声明
本教程仅用于学习, 禁止用于其他用途
QQ群
917400262
边栏推荐
- Invert an array with for
- MySQL implements over partition by (sorting the data in the group after grouping)
- Principle of copyonwritearraylist copy on write
- Docker安装Mysql、Redis
- DISM命令使用小结
- What do you need to know about Amazon evaluation?
- Fix Yum dependency conflict
- Sword finger offer 04: find in 2D array
- Print sparse arrays and restore
- A collection of problems on improving working frequency and reducing power consumption in FPGA design
猜你喜欢

Error reporting injection of SQL injection

Box model

Sqoop installation tutorial

Install Oracle Database

Servlet

Notes sur les questions d'entrevue de la FPGA (IV) - - détecteur de séquence, Code gris dans le domaine de l'horloge croisée, opération de ping - pong, réduction de la perte statique et dynamique, err

Using Internet of things technology to accelerate digital transformation

This point of arrow function

Moteur de modèle de moteur thymeleaf

NFC Development -- the method of using NFC mobile phones as access control cards (II)
随机推荐
Free get | full function version of version control software
Sqoop installation tutorial
Do we really need conference headphones?
Warmly celebrate that yeyanxiu, senior consultant of Longzhi, won the title of "atlassian Certified Expert"
MinGW-W64安装说明
What is a planning BOM?
View controller and navigation mode
Growth Diary 01
FPGA面试题目笔记(二)——同步异步D触发器、静动态时序分析、分频设计、Retiming
[must see for game development] 3-step configuration p4ignore + wonderful Q & A analysis (reprinted from user articles)
Chapter 2 of machine learning [series] logistic regression model
qmake 实现QT工程pro脚本转vs解决方案
Installing and using sublist3r in Kali
verilog实现双目摄像头图像数据采集并modelsim仿真,最终matlab进行图像显示
What do you need to know about Amazon evaluation?
Devsecops in Agile Environment
Install Oracle Database
Linux Installation redis
Reading the registry using batch
All questions and answers of database SQL practice niuke.com