docs: engines module

This commit is contained in:
hyb1996 2017-08-04 16:35:29 +08:00
parent 19dac12614
commit 37dc1966dc
3 changed files with 60 additions and 1 deletions

View File

@ -84,6 +84,11 @@
"type": "markdown",
"path":"documentation"
},
{
"title": "脚本引擎",
"type": "markdown",
"path":"documentation"
},
{
"title": "模块与第三方jar",
"type": "markdown",

View File

@ -0,0 +1,54 @@
# engines
engines模块包含了一些与脚本引擎有关的函数包括运行其他脚本关闭脚本等。
### engines.execScript(name, script\[, config\])
* name \<String\> 要运行的脚本名称。这个名称和文件名称无关,只是在任务管理中显示的名称。
* script \<String\> 要运行的脚本内容。
* config \<Object\> 运行配置项
* delay \<Number\> 延迟执行的毫秒数默认为0
* loopTimes \<Number\> 循环运行次数默认为1
* interval \<Number\> 循环运行时两次运行之间的时间间隔默认为0
* path \<Array\> | \<String\> 指定脚本运行的目录。这个路径会用于require时寻找模块文件。
在新线程中运行脚本script。返回一个\[ScriptExecution\](#ScriptExecution)对象。
### engines.execScriptFile(path, \[config\])
* path \<String\> 要运行的脚本路径。
* config \<Object\> 运行配置项
* delay \<Number\> 延迟执行的毫秒数默认为0
* loopTimes \<Number\> 循环运行次数默认为1
* interval \<Number\> 循环运行时两次运行之间的时间间隔默认为0
* path \<Array\> | \<String\> 指定脚本运行的目录。这个路径会用于require时寻找模块文件。
在新线程中运行脚本文件path。返回一个\[ScriptExecution\](#ScriptExecution)对象。
### engines.execAutoFile(path, \[config\])
* path \<String\> 要运行的录制文件路径。
* config \<Object\> 运行配置项
* delay \<Number\> 延迟执行的毫秒数默认为0
* loopTimes \<Number\> 循环运行次数默认为1
* interval \<Number\> 循环运行时两次运行之间的时间间隔默认为0
* path \<Array\> | \<String\> 指定脚本运行的目录。这个路径会用于require时寻找模块文件。
在新线程中运行录制文件path。返回一个\[ScriptExecution\](#ScriptExecution)对象。
### engines.stopAll()
停止所有正在运行的脚本。包括当前脚本自身。
### engines.stopAllAndToast()
停止所有正在运行的脚本并显示停止的脚本数量。包括当前脚本自身。
# ScriptExecution
执行脚本时返回的对象,可以通过他获取执行的引擎、
### ScriptExecution.getEngine()
### ScriptExecution.getConfig()
### ScriptExecution.getSource()
先写到这儿吧:-)

View File

@ -1,6 +1,6 @@
var script = "toast('Hello, Auto.js');" +
"sleep(3000);" +
"toast('略略略');";
var execution = engines.execScript(script);
var execution = engines.execScript("Hello", script);
sleep(1000);
execution.getEngine().forceStop();