Tooth uncle tutorial is easy to understand
Autojs software script store has a lot of scripts, a manual download is too troublesome to give, we write a script to download a batch
The effect
It’s much faster to simulate a manual download, and you don’t have to analyze protocols and things like that
The script process
while (1) {
let listParentView = getListParentView();
var len = listParentView.childCount();
for (var i = 0; i < len; i++) {
let itemView = listParentView.child(i);
let downloadButton = itemView.child(0).child(1);
downloadButton.click();
}
slideFromBottomToTop(listParentView);
}
Copy the code
- Gets the store script list control
- Traverse the list
- Download entry
- After downloading the current page, scroll the list
Deal with a few minor issues
- Once the control is found, it visualizes the control, that is, displays the area of the found control on the screen
Display control area method:
Display a full screen hover window, add a text control, set the background of the text control to a box,
The area of the box corresponds to the area of the control to display
Var w = floaty. RawWindow (<frame> <text id="content" gravity="center"> </text> </frame>); ui.run(function () { w.setSize(-1, -1); w.setTouchable(false); }); ui.run(function () { contentView.attr("w", width + "px"); contentView.attr("h", height + "px"); contentView.attr("x", left); contentView.attr("y", top - status_bar_height); setBackgroundRoundedRectangle(contentView); });Copy the code
- How to determine if the current list control is collected?
As you download, record the titles of the files you are downloading. If they are all recorded, you are done
- How do I know if I’m scrolling to the bottom?
Record the name of the last item in the list before scrolling,
After scrolling, record the name of the last item in the list,
If both are the same before and after the scroll, the scroll has reached the end
- Do you need to consider the height of the status bar?
Look at the phone, some phone suspension window can cover the status bar, some phones can not, based on the actual test
Get the status bar height:
const resources = context.getResources();
const status_bar_height = resources.getDimensionPixelSize(
resources.getIdentifier("status_bar_height", "dimen", "android")
);
Copy the code
- Scroll controls use that API
view.scrollForward();
Copy the code
- Get control height
view.bounds().height();
Copy the code
The download is complete
The test environment
Mi 11 Pro Android version: 12 Autojs version: 9.1.11
Quotes.
Ideas are the most important, other baidu, Bing, StackOverflow, Github, Android docs, AutoJS docs, and last but not least, ask in the group
This tutorial is for study only. It is not allowed to be used for other purposes