当前位置:网站首页>Autojs, read one line, delete one line, and stop scripts other than your own

Autojs, read one line, delete one line, and stop scripts other than your own

2022-06-11 06:14:00 Jiuli AJ

New exchange group 917400262
Welcome to join v Group , Communicate with the great gods
disclaimer : The content of this blog is only for learning 、 Share and communicate , We do not guarantee the correctness of the content . By using the content of this blog, the following problems have nothing to do with this blog . When using this blog code , Represents that you have accepted the disclaimer of this blog

Body part

Catalog

 Insert picture description here

Read a row and delete a row

function read_delete() {
    // Delete first line 
    var path = "/sdcard/gjc.txt";//txt Text path 
    var reg = /^\s+|s+$/g; // Match invalid blank lines 
    var txt = files.read(path).replace(reg, "").split("\n");
    let ret_text = txt[0];
    log(ret_text.length);
    if (txt != "") {
        txt.splice(0, 1); // Delete 
        files.write(path, txt.join("\n"));
        if (ret_text.length > 0) {
            return ret_text.trim();

        };
    } else {
        
        return " clothes "

    };

    file.close();
};

Two methods of traversal ( Get the current screen text )

console.show();
className("TextView").find().forEach(function(tv){
    if(tv.text() != ""){
        log(tv.text());
    }
});

Method 2

console.show();
className("TextView").find().forEach(function(tv){
    if(tv.text() != ""){
        log(tv.text());
    }
});

Node click function

function Click(node) {
// Jiuli super node click function ,qq1906507927. The problem of 
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
}

Determine if the software has been installed

if (app.getPackageName("QQ")) {
log(" already installed ")
}else{
log(" Not installed ")
}

Stop all scripts except yourself

engines.all().map((ScriptEngine) => {
if (engines.myEngine().toString() !== ScriptEngine.toString()) {
ScriptEngine.forceStop();
}
});

Data read save delete

// Save local data 
function setStorageData(name, key, value) {
const storage = storages.create(name);
storage.put(key, value);
};
// Read local data 
function getStorageData(name, key) {
const storage = storages.create(name);
if (storage.contains(key)) {
return storage.get(key, "");
};
// Default return undefined
};
// Delete local data 
function delStorageData(name, key) {
const storage = storages.create(name);
if (storage.contains(key)) {
storage.remove(key);
};
};

Get the contents of the clipboard

 function  Get the contents of the clipboard () {
        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  Timer  = setInterval(() => {
                if (l) {
                    log(" Shear board content :" + getClip())
                    w.close();
                    clearInterval( Timer );
                }
            }, 1)
        })
        let str = getClip()
        l = true
        return str
    }

Practical replacement replace Code

var  answer 2=" The answer is as follows ...."
var  answer =  answer 2.replace(" The answer is as follows ","");
// Replace the answer below with blank , Selected from actual combat projects , Data desensitization has been performed 

Other small tip:
When used in a thread ui Function operation , Need to use ui.run, Otherwise, an error will be reported 4.1 The free version can be adapted to most machines without this , But the cloud machine does not support

Statement

This tutorial is only for learning , It is forbidden to use it for other purposes

QQ Group

917400262

原网站

版权声明
本文为[Jiuli AJ]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/162/202206110603359144.html