Source code of current page activities of APP developed by autojs root free script engine

Keywords: Android Javascript

Explain

The code provided in this article is for reference only. Not recommended for production environments.
Some places may need to be modified on the latest version of Auto.js to run.

Introduction to Auto.js

Auto.js is a kind of auxiliary work that can simulate a series of interface actions through code, similar to the key wizard, by using the "auxiliary functions" of Android system.
Different from the "key Wizard", its simulation action is not simply realized by using the fixed coordinate point on the interface, but similar to that of win, which is realized by finding the window handle.

Auto.js uses JavaScript as the scripting language, and Rhino 1.7.7.2 is currently used as the scripting engine, which supports ES5 and some ES6 features.

Recommended tutorial

Auto.js Pro full resolution ROOT free drainage script development video tutorial (HD ultra clear 1080p)

Developing documents

Auto.js Pro development document
The document is still in the process of improvement, and there may be a discrepancy between the document description and the actual code behavior.

Why do you use Auto.js Pro to develop scripts? What are the characteristics?

There are many reasons why I am attracted to Auto.js Pro. The main reasons are:

  • Auto.js Pro can develop ROOT free Android script
  • Based on node operation, Auto.js Pro can develop full resolution scripts and automatically adapt to various Android models.
  • Rich UI components of Auto.js Pro can customize various Android interfaces
  • javascript used by Auto.js Pro has elegant syntax and strong code readability.
  • The command Library of Auto.js Pro is very rich with many interfaces.
  • The size of Auto.js Pro script file is relatively small. 1000 lines of code, the packed apk file is only 3-5M, and there is no advertisement.

Sample code

// This code is provided by Feiyun script circle www.feiyunjs.com
var window = floaty.window(
    <frame gravity="center">
        <text id="text" textSize="12sp" textColor="#FFFF00FF"/>
    </frame>
);

window.exitOnClose();

var i = 0;

setInterval(function(){
   
   
   
//File path
var path = "/sdcard/1.txt";
//File contents to write
//Open file in write mode
var file = open(path, "a");
    //file:week(set)
//write file
    file.writeline(["\n\n Current package name: " + currentPackage() + "\n",
           "Current app name:  " + app.getAppName(currentPackage())+ "\n",
           "current activity:  " + currentActivity()]);
//Close file


//Add a line "cheerleading"
file.writeline("");
//Add a line "hahahaha"
//file.writeline("hahahaha");
//Add two lines of ccc, ddd
//file.writelines(["ccc", "ddd"]);
//Output buffer
file.flush();
//Close file
file.close(); 
if(i == 5){
        exit()
    }
}, 4000);



window.text.click(()=>{
    window.setAdjustEnabled(!window.isAdjustEnabled());
    setClip(currentActivity());
    toast("   Already copied\n current activity:\n " + currentActivity())
});

setInterval(()=>{
    //Operations on the control need to be performed in the UI thread
    ui.run(function(){
        window.text.setText(dynamicText());
    });
}, 1000);


function dynamicText(){
     var date = new Date();
    var str = util.format("time: %d:%d:%d\n\n", date.getHours(), date.getMinutes(), date.getSeconds());

    str += util.format("Memory usage: %d%%\n\n", getMemoryUsage());
    str += "Current package name: \n" + currentPackage() + "\n\n";
    str += "Current app name: \n" + app.getAppName(currentPackage())+ "\n\n";
    str += "current activity: \n" + currentActivity();
    return str;
}

//Get memory usage
function getMemoryUsage(){
    var usage = (100 * device.getAvailMem() / device.getTotalMem());
    //Keep one decimal place
    return Math.round(usage * 100) / 100;
}

Posted by dual_alliance on Tue, 29 Oct 2019 11:30:41 -0700