> For the complete documentation index, see [llms.txt](https://docs.gpmautomate.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.gpmautomate.com/automate-zh/cao-zuo-zhi-nan/variables/set-variable.md).

# 设置变量

这是一个用于在脚本中创建或更改变量（数据容器）值的操作。此外，此操作还允许您在主界面上创建输入框，帮助用户在开始运行工具之前自行填写信息。

* 允许用户输入（Allow user input from the interface）：您可以选中此项以在主屏幕上创建空白框，允许用户在运行之前直接输入值到脚本中。
* 输入必填（Input required）：选择此项后，系统将要求用户必须填写足够的数据或选择文件才能点击运行按钮。如果留空，工具将立即报告错误，以避免因忘记输入信息而导致的错误运行。

系统支持4种输入数据类型（Input Type），包括：

#### 1. 文本输入类型（Text）

当您希望用户从键盘输入一个字符串、文本或数字值时使用。

* 实际示例：您将变量命名为 `$textContent`。当用户在界面上的输入框中输入内容 `"hello world"` 时，变量 `$textContent` 的值将变为 `"hello world"` (`$textContent = "hello world"`)。

#### 2. 文件选择类型（File）

当脚本需要处理用户计算机上的特定文件（如图像文件、数据文件、配置文件等）时使用。在用户界面上将出现一个文件夹图标，用户可以点击并浏览文件。

* 实际示例：用户选择名为 `bruh.png` 的文件，该文件位于 D 盘。变量 `$filePath` 将接收到该文件的绝对路径：`"D:\materials\bruh.png"` (`$filePath = "D:\materials\bruh.png"`)。您可以直接使用这个变量 `$filePath` 传递到后续步骤的文件上传操作中。

#### 3. 复选框类型（Checkbox）

复选框是一个界面组件，允许用户启用或禁用一个二元选项（是/否，开/关，同意/不同意）。

* 特点：当被选中时，变量将接收值 `True`。当取消选中时，变量将接收值 `False`。
* 实际示例：您创建一个标签为 *"选择以下订单 / Check to place an order"* 的选项，绑定到变量 `$checkBox`。如果用户选中此框，变量 `$checkBox` 的值将为 `True` (`$checkBox = True`)。您可以使用 If 语句来检查：如果 `$checkBox = True`，则执行支付步骤。

#### 4. 下拉列表选择类型（Combo Box）

下拉列表（Combo Box，类似于 Dropdown）是一个界面组件，显示一系列可用选项，允许用户在任何时刻选择一个唯一的值。此功能最大限度地减少了拼写错误或数据格式错误的输入。

* 特点：在需要选择固定信息（如国家、行业、产品类型、活动状态等）时，有助于保持数据的一致性。
* 实际示例：您配置一个包含多个国家的列表，绑定到变量 `$country`。当用户打开脚本并从下拉列表中选择 `"United States"` 时，Automate 中的变量 `$country` 将立即接收到值 `"United States"` (`$country = "United States"`)。


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.gpmautomate.com/automate-zh/cao-zuo-zhi-nan/variables/set-variable.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
