list of autojs actions - download script store code

Uncle Tooth Tutorial is simple and easy to understand

There are many scripts in the script store that comes with the autojs software. It is too troublesome to download manually one by one. Let's write a script and download it in batches.

Effect

In this way, the simulation of manual download is much faster, and there is no need to analyze the protocol and the like, and the difficulty is extremely low.

Script flow

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);
}
复制代码
  1. Get store script list control
  2. iterate over the list
  3. Download entry
  4. After the current page is downloaded, scroll the list

Handle a few small problems

  1. After the control is found, the visualization of the control, that is, on the screen, shows the area of ​​the found control

Display control area method:

Display a full-screen floating window, add a text control, set the background of the text control to a box,

The area of ​​the box is consistent with the data of the control area to be displayed

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);
  });
复制代码
  1. How to judge that the current list control has been collected?

When downloading, record the title of the downloaded file. If it has been recorded, it means the collection is complete.

  1. How can I tell if the scroll is over?

record the name of the last item in the list before scrolling,

Record the name of the last item in the list after scrolling,

If the two are the same before and after scrolling, it means scrolling to the end

  1. Need to consider the status bar height?

Looking at the mobile phone, some mobile phone floating windows can cover the status bar, and some mobile phones cannot. The actual test shall prevail.

Get the status bar height:

const resources = context.getResources();
const status_bar_height = resources.getDimensionPixelSize(
  resources.getIdentifier("status_bar_height", "dimen", "android")
);
复制代码
  1. The scroll control uses that api
view.scrollForward();
复制代码
  1. Get control height
view.bounds().height();
复制代码

Download completed

test environment


Phone: Mi 11 Pro
Android Version: 12
Autojs Version: 9.1.11


famous quotes

The idea is the most important, other Baidu, bing, stackoverflow, github, Android documentation, autojs documentation, and finally the group to ask --- Uncle Tooth Tutorial

Statement

Part of the content is from the Internet. This tutorial is only for learning, and it is prohibited to use it for other purposes

.

Guess you like

Origin juejin.im/post/7079699102707122206