> For the complete documentation index, see [llms.txt](https://chaoses-ib.gitbook.io/directory-opus/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://chaoses-ib.gitbook.io/directory-opus/guan-fang-shou-ce/readme.zh-8/script_functions.zh.md).

# 脚本函数

*脚本函数* [在按钮或菜单中直接定义](/directory-opus/guan-fang-shou-ce/readme.zh-6/readme.zh-1.md)-它们是按钮函数第三种类型，除了 *标准函数* 和 *MS-DOS 批处理函数*。

![](https://3597805814-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3XSZSwWow0fDf6fQJobd%2Fuploads%2Fgit-blob-5bad69ea7ca92c76bc67ebfd1a72008ea7111ff3%2Fscript_function.png?alt=media)

上面的截图是脚本函数的示例，它选择当前源文件列表中的所有“高分辨”图像（定义为垂直分辨率大于或等于 1080 像素的图像）。

脚本编辑器顶部的下拉菜单用于指定脚本语言 - 在这里它设置为 *VBScript*。**默认**按钮允许您将脚本“模板”保存为特定语言的默认模板，并随时恢复为默认设置。

[**OnClick**](/directory-opus/guan-fang-shou-ce/readme.zh-10/readme.zh-3/readme.zh-1/onclick.zh.md) 函数是一个已定义的脚本入口点，Opus 将在每次单击按钮（或按下热键）时调用该函数。传入它的\*\*[ClickData](/directory-opus/guan-fang-shou-ce/readme.zh-10/readme.zh-3/readme.zh/clickdata.zh.md)\*\* 对象提供许多属性和方法，您可以使用它们与启动该函数的文件窗口进行交互。

当函数编辑器设置为运行*脚本函数*时，它将具有三个独立的标签页，将该函数分割为：

* **修饰符**：应用于脚本的任何 [命令修饰符](/directory-opus/guan-fang-shou-ce/readme.zh-6/readme.zh-1/command_modifiers.zh.md)（例如 **@filesfromdroponly**）。
* **脚本代码**：定义脚本的实际代码。
* **资源**：脚本[资源](/directory-opus/guan-fang-shou-ce/readme.zh-8/readme.zh-5.md)。

在函数编辑器的底部，**运行**按钮允许您立即测试当前脚本，而无需退出*自定义*模式。当您使用**运行**按钮时，编辑器下方将显示一个输出面板，其中显示任何错误或脚本文本输出。

**资源**标签页定义脚本可用的任何[资源](/directory-opus/guan-fang-shou-ce/readme.zh-8/readme.zh-5.md)。对话框是主要类型的资源，但也支持字符串资源，允许您用多种语言定义字符串。

![](https://3597805814-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3XSZSwWow0fDf6fQJobd%2Fuploads%2Fgit-blob-1ddb91586d63b9aa7e2316d04759dd98ee11509e%2Fimage063.png?alt=media)

虽然您可以根据需要在 XML 中手动编写对话框资源，但使用内置[对话框编辑器](/directory-opus/guan-fang-shou-ce/readme.zh-8/readme.zh-3/readme.zh/readme.zh.md)进行设计会容易得多。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://chaoses-ib.gitbook.io/directory-opus/guan-fang-shou-ce/readme.zh-8/script_functions.zh.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
