Template framework sharing for quickly building AutoJS automation script projects

  • This project is a template framework for quickly building AutoJS automation script projects: https://github.com/TonyJiangWJ/AutoScriptBase

  • The currently implemented functions are as follows:

    • Graphical configuration
    • Multi-script execution scheduling to prevent multiple different scripts from preempting the foreground RunningQueueDispatcher
    • Encapsulates support for multi-script locks  LockableStorage, blocks writing and returns whether the writing is successful or not, to achieve the purpose of mutual exclusion of locks
    • Encapsulates regular search tools based on text and ID controls  WidgetUtils, supports control waiting, batch acquisition of matching controls, etc.
    • The log tool  LogUtilscan save logs to files, supports log levels error\warn\info\log\debug, different levels of logs are displayed in different colors in the console, and the log files are written to different files after opening the log file.
      • The log supports synchronous writing to files and asynchronous writing to files. Writing this is just to achieve double buffering and asynchronous writing.
      • Asynchronous log files are not flushed to the file immediately, and will not be fully written until the script is fully executed
      • So if you need performance, choose to enable asynchronous mode, otherwise use synchronous mode.
    • Supported  github release api script manual update function
    • Support automatic judgment of Root and barrier-free automatic execution operations Automator
    • Encapsulates a text floating window tool FloatyUtil
    • Supports automatic unlocking of devices, and also supports extended custom unlocking
    • Supports simulated gestures to automatically lock the screen, and supports extended custom lock screen codes
    • Support Alipay gesture unlock
    • Support to add timing tasks through code  Timers from the author  SuperMonster003
    • Support automatic click to authorize screenshot permission  TryRequestScreenCapture from the author  SuperMonster003
    • Support configuration information import and export and configuration information encryption
    • The accessibility function is supported automatically after being authorized by ADB. For details on how to use ADB, please Google or Baidu yourself. For different software, please replace the package name by yourself: the Pro version  org.autojs.autojspro can be  context.getPackageName() obtained through
    adb shell pm grant org.autojs.autojs android.permission.WRITE_SECURE_SETTINGS
    • Detailed use of ADB
    • Encapsulates common methods  CommonFunction such as saving runtime data, countdown delay, etc.
    • lib/autojs-tools.dex Some Java methods for updating are encapsulated in , which are used to optimize script execution performance. For the source code, see auto-js-tools
    • Execution  unit/获取当前页面的布局信息.js can view the control text and id information in the current page to facilitate the development of scripts
  • For details, see the description information in each js file.

development note

    1. Download this repository
    1. CONFIG_STORAGE_NAME Modify the and  in config.js PROJECT_NAME
      // Different projects need to set different storageName, otherwise the configuration information will be confused. 
      let CONFIG_STORAGE_NAME = 'autoscript_version' 
      let PROJECT_NAME = 'AutoJS scaffolding'
    1. To develop a main business logic code,  the methods main.js in  the replacement mainLoop() , such as creating  core/MainRunner.js content, refer to the following
      function MainRunner() { 
    
        this.exec = function () { 
          // execute the main business logic 
        } 
      } 
      module.exports = new MainRunner()

    Then  main.js call in:

      let mainExecutor = require('./core/MainExecutor.js') 
    
      //.. The common code in main.js can be modified as appropriate or not left. 
    
      // The development mode does not wrap exception capture, which is convenient for viewing error messages 
      if (config.develop_mode) { 
        mainExecutor.exec() 
      } else { 
        try { 
          mainExecutor.exec() 
        } catch (e) { 
          commonFunctions.setUpAutoStart(1) 
          errorInfo('Execution exception, restart after 1 minute' + e) 
          ​​commonFunctions .printExceptionStack(e) 
        } 
      } 
    
      //....
    1. Put all the modified code folders into the root directory of the mobile phone /脚本/as follows /脚本/AutoScriptBase/
    1. Open the AutoJS software, pull down to refresh and you can see it , click to enter  and AutoScriptBaserun main.js
    • 5.1 The script execution depends on the accessibility service, please enable the accessibility permission of AutoJS in the automatic pop-up interface, or let the script automatically obtain the accessibility permission directly through ADB authorization
    • 5.2 In addition, other required application permissions  后台弹出界面 显示悬浮窗 修改系统配置(可选) are

development assistance

  • Online color picking tool: picture base64 color picking
  • Online multi-point color picking path generation:  multi-point color picking auxiliary tool
  • Unlock function extension assistance:unit/获取锁屏界面控件信息.js
  • There is currently only one function, such as real-time binarization of pictures  test/visual_test/可视化测试工具.js , just follow the prompts after running.
  • The visual configuration tool is implemented based on the webvie and vue frameworks. The H5 content is under vue_configs. The new configuration items can only be modified vue_configs/js/commponets/configuration.js and  config.js two files, and other public ones can be ignored. If you know vue, you can modify it as you want

Guess you like

Origin blog.csdn.net/m0_55125030/article/details/113838532