当前位置:网站首页>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 边栏推荐
- C # getting started series (12) -- string
- 使用Visual Studio 2017创建简单的窗口程序
- Auto.js学习笔记4:autojs打包后,大部分华为等大牌子手机无法安装?利用模拟器远程在autoPro里签名打包可以解决该问题。
- Introduction to applet
- 榜样访谈——董宇航:在俱乐部中收获爱情
- 哈希表的理论讲解
- 004:aws data Lake solution
- Auto.js学习笔记7:js文件调用另一个js文件里的函数和变量,解决调用失败的各种问题
- 【极术公开课预告】Arm最强MCU内核Cortex-M85处理器,全方位助力物联网创新(有抽奖)
- Explanation of the principle of MySQL's leftmost matching principle
猜你喜欢

SAP Hana error message sys_ XSA authentication failed SQLSTATE - 28000

ThreadLocal
![[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)

List of computer startup shortcut keys

NiO principle

Theoretical explanation of hash table

Auto.js调试:使用雷电模拟器的网络模式进行调试

Clickhouse column basic data type description

Ceph性能优化与增强

Auto.js学习笔记4:autojs打包后,大部分华为等大牌子手机无法安装?利用模拟器远程在autoPro里签名打包可以解决该问题。
随机推荐
《真北》读书笔记
Autojs微信研究:微信不同的版本或模拟器上的微信里的控件ip是不同的。
2022 极术通讯-安谋科技迎来发展新机遇
Dazzle the "library" action - award solicitation from the golden warehouse of the National People's Congress - high availability failover and recovery of kingbasees cluster
[cloud native] establishment of Eureka service registration
总有一根阴线(上影线)会阻止多军前进的脚步,总有一个阳线(下影线)会阻挡空军肆虐的轰炸
Difference between MySQL unreal reading and non repeatable reading
小程序介绍
Theoretical explanation of hash table
QQ,微信能聊天都靠它(socket)?
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"
Golandidea 2020.01 cracked version
string类对象的访问及遍历操作
002:数据湖有哪些特征
Ceph如何改善存储性能以及提升存储稳定性
卖疯了的临期产品:超低价、大混战与新希望
What are the software testing requirements analysis methods? Let's have a look
List、Set、Map的区别
Microservice gateway
硬盘 SMART 检测参数详解