diff --git a/app/src/main/assets/help/catalogue.json b/app/src/main/assets/help/catalogue.json index fb0922dc..ab01a3bd 100644 --- a/app/src/main/assets/help/catalogue.json +++ b/app/src/main/assets/help/catalogue.json @@ -84,6 +84,11 @@ "type": "markdown", "path":"documentation" }, + { + "title": "脚本引擎", + "type": "markdown", + "path":"documentation" + }, { "title": "模块与第三方jar", "type": "markdown", diff --git a/app/src/main/assets/help/documentation/脚本引擎.md b/app/src/main/assets/help/documentation/脚本引擎.md new file mode 100644 index 00000000..f0acfdcb --- /dev/null +++ b/app/src/main/assets/help/documentation/脚本引擎.md @@ -0,0 +1,54 @@ +# engines + +engines模块包含了一些与脚本引擎有关的函数,包括运行其他脚本,关闭脚本等。 + +### engines.execScript(name, script\[, config\]) +* name \ 要运行的脚本名称。这个名称和文件名称无关,只是在任务管理中显示的名称。 +* script \ 要运行的脚本内容。 +* config \ 运行配置项 + * delay \ 延迟执行的毫秒数,默认为0 + * loopTimes \ 循环运行次数,默认为1 + * interval \ 循环运行时两次运行之间的时间间隔,默认为0 + * path \ | \ 指定脚本运行的目录。这个路径会用于require时寻找模块文件。 + +在新线程中运行脚本script。返回一个\[ScriptExecution\](#ScriptExecution)对象。 + +### engines.execScriptFile(path, \[config\]) +* path \ 要运行的脚本路径。 +* config \ 运行配置项 + * delay \ 延迟执行的毫秒数,默认为0 + * loopTimes \ 循环运行次数,默认为1 + * interval \ 循环运行时两次运行之间的时间间隔,默认为0 + * path \ | \ 指定脚本运行的目录。这个路径会用于require时寻找模块文件。 + +在新线程中运行脚本文件path。返回一个\[ScriptExecution\](#ScriptExecution)对象。 + +### engines.execAutoFile(path, \[config\]) +* path \ 要运行的录制文件路径。 +* config \ 运行配置项 + * delay \ 延迟执行的毫秒数,默认为0 + * loopTimes \ 循环运行次数,默认为1 + * interval \ 循环运行时两次运行之间的时间间隔,默认为0 + * path \ | \ 指定脚本运行的目录。这个路径会用于require时寻找模块文件。 + +在新线程中运行录制文件path。返回一个\[ScriptExecution\](#ScriptExecution)对象。 + +### engines.stopAll() + +停止所有正在运行的脚本。包括当前脚本自身。 + +### engines.stopAllAndToast() + +停止所有正在运行的脚本并显示停止的脚本数量。包括当前脚本自身。 + +# ScriptExecution + +执行脚本时返回的对象,可以通过他获取执行的引擎、 + +### ScriptExecution.getEngine() + +### ScriptExecution.getConfig() + +### ScriptExecution.getSource() + +先写到这儿吧:-) \ No newline at end of file diff --git a/app/src/main/assets/sample/脚本引擎/运行新的脚本任务.js b/app/src/main/assets/sample/脚本引擎/运行新的脚本任务.js index 96d2a9b5..f904f06a 100644 --- a/app/src/main/assets/sample/脚本引擎/运行新的脚本任务.js +++ b/app/src/main/assets/sample/脚本引擎/运行新的脚本任务.js @@ -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(); \ No newline at end of file