当前位置:网站首页>Auto. JS learning note 9: basic methods such as using the script engine, starting the script file with the specified path, and closing
Auto. JS learning note 9: basic methods such as using the script engine, starting the script file with the specified path, and closing
2022-06-12 09:54:00 【PYB3】
Declare that I use autojs yes 4.1.1 edition
Catalog
engines.execScript(name, script[, config])
Run the specified path file script :engines.execScriptFile(path[, config])
Recording file script to run :engines.execAutoFile(path[, config])
Configuration during script execution :ScriptConfig
Stop script :engines.stopAll()
Stop the script and display the number of scripts :engines.stopAllAndToast()
Get the script engine object of the current script :engines.myEngine()
Return to the script Directory :ScriptEngine.cwd()
Check official documents for other details
Examples of actual development code
The script engine :engines
engines The module contains some scripts related to the environment 、 Script run 、 Script engine related functions , Including running other scripts , Close scripts, etc .
engines.myEngine().cwd();// Get the directory where the script is located
engines.execScript(name, script[, config])
name{string} The name of the script to run . This name has nothing to do with the file name , Just the name displayed in task management .script{string} What script to run .config{Object} Run configuration itemdelay{number} Number of milliseconds delayed execution , The default is 0loopTimes{number} Number of cycles , The default is 1.0 For infinite cycles .interval{number} The time interval between two runs when a loop runs , The default is 0path{Array} | {string} Specify the directory where the script runs . These paths will be used for require When looking for module files .
Run the script in the new script environment script. Return to one ScriptExecution object .
The so-called new scripting environment , The designation is , The variables in the script are not shared with those in the original script , also , The script will run in the new thread .
A simple example :
engines.execScript("hello world", "toast('hello world')");Example of cyclic operation :
// every other 3 Run the script once per second , loop 10 Time
engines.execScript("hello world", "toast('hello world')", {
loopTimes: 10,
interval: 3000
});Run the specified path file script :engines.execScriptFile(path[, config])
path{string} The path of the script to run .config{Object} Run configuration itemdelay{number} Number of milliseconds delayed execution , The default is 0loopTimes{number} Number of cycles , The default is 1.0 For infinite cycles .interval{number} The time interval between two runs when a loop runs , The default is 0path{Array} | {string} Specify the directory where the script runs . These paths will be used for require When looking for module files .
engines.execScriptFile("/sdcard/ Script /1.js");// A simple example Recording file script to run :engines.execAutoFile(path[, config])
path{string} The path of the recording file to run .config{Object} Run configuration itemdelay{number} Number of milliseconds delayed execution , The default is 0loopTimes{number} Number of cycles , The default is 1.0 For infinite cycles .interval{number} The time interval between two runs when a loop runs , The default is 0path{Array} | {string} Specify the directory where the script runs . These paths will be used for require When looking for module files .
Run the recording file in the new script environment path. Return to one ScriptExecutionScriptExecution object .
engines.execAutoFile("/sdcard/ Script /1.js"); // Example Configuration during script execution :ScriptConfig
delay
- {number}
Number of milliseconds delayed execution
interval
- {number}
The time interval between two runs when a loop runs
loopTimes
- {number}
Number of cycles
getPath()
- return {Array}
Returns an array of strings representing the path the script runtime module is looking for .
Stop script :engines.stopAll()
Stop all running scripts . Include the current script itself .
Stop the script and display the number of scripts :engines.stopAllAndToast()
Stop all running scripts and display the number of stopped scripts . Include the current script itself .
Get the script engine object of the current script :engines.myEngine()
The object can be execArgv To get his running parameters , Including external parameters 、intent etc. . for example :
log(engines.myEngine().execArgv);The running parameters of a normal script are usually empty , If it is started through the broadcast of the scheduled task, it can obtain the started intent.
Return to the script Directory :ScriptEngine.cwd()
- return {string} Is a directory It's not the path. Pay attention
Return the path of script execution . For a script file, it is the folder where the script is located ; For other scripts , For example, string scripts , Then for null Or the setting value during execution .
ScriptEngine.getSource()
- return { ScriptSource}
Returns the script object being executed by the current script engine .
log(engines.myEngine().getSource());// A simple example Other details Official documents
Examples of actual development code
toastLog(" The startup script ")
var path = engines.myEngine().cwd();// Get script directory
toastLog(' Script path :'+path)
engines.execScriptFile(path+"/AutoWeiXinNews.js", {
loopTimes: 1,
interval: 6000
});// A simple example
engines.stopAllAndToast();// Stop all scripts 边栏推荐
- 【云原生】Eureka服务注册的搭建
- IV Transforming regular expressions into finite state automata: DFA minimization
- Golandidea 2020.01 cracked version
- II Transforming regular expressions into finite state automata: NFA state machine recognizes input strings
- I Regular expression to finite state automata: regular expression to NFA
- Combat tactics based on CEPH object storage
- 7-13 地下迷宫探索(邻接表)
- TAP 系列文章3 | Tanzu Application Platform 部署参考架构介绍
- Hotspot Metaspace
- 传输层协议 ——— TCP协议
猜你喜欢

gnu-efi开发环境设置

Overview of software definition storage (one article is enough)
![[preview of the open class of Jishu] arm's strongest MCU core cortex-m85 processor helps the innovation of the Internet of things in an all-round way (there is a lottery)](/img/25/c3af3f51c04865820e3bbe2f010098.png)
[preview of the open class of Jishu] arm's strongest MCU core cortex-m85 processor helps the innovation of the Internet of things in an all-round way (there is a lottery)

TAP 系列文章3 | Tanzu Application Platform 部署参考架构介绍

Is it necessary to separate databases and tables for MySQL single table data of 5million?

SAP Hana error message sys_ XSA authentication failed SQLSTATE - 28000

JVM virtual machine

Crazy temporary products: super low price, big scuffle and new hope

Combat tactics based on CEPH object storage

Web3.0与数字时尚,该如何落地?
随机推荐
榜样访谈——董宇航:在俱乐部中收获爱情
Theoretical explanation of hash table
TAP 系列文章3 | Tanzu Application Platform 部署参考架构介绍
Use of MYCAT
抽象类和接口
传输层协议 ——— TCP协议
UE4_以现成资源探索创建背景场景的方法
Research progress of DNA digital information storage
价值投资.
UEFI EDKII 编程学习
Li Yang, a scientific and technological innovator and CIO of the world's top 500 group: the success of digital transformation depends on people. Decision makers should always focus on "firewood"
III Regular expression to finite state automata: NFA to DFA
Introduction to on-line circuit simulation and open source electronic hardware design
The Dragon Boat Festival is in good health -- people are becoming more and more important in my heart
2022 极术通讯-安谋科技纷争尘埃落定,本土半导体产业基石更稳
I Regular expression to finite state automata: regular expression to NFA
MySQL optimized slow log query
Mysql5.7 partition table
JVM garbage collection
Principle analysis of mongodb storage engine wiredtiger