What is auto.js

(*-*)浩
Release: 2020-09-17 11:30:28
Original
32459 people have browsed it

"auto.js" is a script framework based on JavaScript language running on the Android platform. The main working principle of "auto.js" is based on the auxiliary service "AccessibilityService".

What is auto.js

Auto.js uses the "auxiliary function" of the Android system to implement auxiliary work similar to the key wizard, which can simulate a series of interface actions through code.

Different from the "Button Wizard", its simulated actions are not simply implemented using fixed coordinate points on the interface, but similar to Win, using window handles to achieve this. This is quite grace.

Because Auto.js is based on JavaScript, it is recommended to learn the basic syntax and built-in objects of JavaScript before learning the API of Auto.js. You can use the JavaScript tutorial to learn.

If you want to use TypeScript to develop, a developer has announced a tool that can use TypeScript for Auto.js development, see Auto.js DevTools.

If you want to develop Auto.js on a computer instead of a mobile phone, you can use VS Code and the corresponding Auto.js plug-in so that the script edited on the computer can be pushed to the mobile phone to run, see Auto.js-VSCode -Extension.

The "automatic operation" part can be roughly divided into control-based and coordinate-based operations. Coordinate-based operations are the methods used by script software such as traditional button wizards and touch wizards. They use screen coordinates to click and long press. Specify the position to simulate the operation to achieve the goal. For example, click(100, 200), press(100, 200, 500), etc. This method is more feasible in game scripts, combined with the functions of finding pictures and colors, and coordinate scaling It can also achieve better compatibility. However, this method is difficult to achieve the desired effect for general software scripts, and this method requires Android version 7.0 or above or root privileges to execute. Therefore, for general software scripts (such as batch addition Contacts, automatically extract SMS verification codes, etc.), we use control-based simulation operation methods, combined with notification events, key events, etc. to achieve a better workflow.

In addition to development documents, Problems encountered by individuals are recorded here

The loop statement in the UI thread loops multiple times and an error is reported

Auto.js (hereinafter referred to as AJ) To modify the properties of the interface, you need to Using

ui.run(function(){
        //TODO
});
Copy after login

It is not recommended to use a large amount of logic code within a function. You should try to only include a small amount of code that modifies the UI. Otherwise, an error will be reported

Only the original thread that created a view hierarchy can touch its views.

For example, code like this is very likely to cause problems.

ui.run(function(){
    for(var i=0;i<len;i++){
		//数据准备操作
		//修改界面内容
	}
});
Copy after login

should be changed to:

 for(var i=0;i<len;i++){
	//数据准备
	ui.run(function(){
		//修改界面内容
		
    });
}
Copy after login

The above is the detailed content of What is auto.js. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!