> 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/blocks/if-else-if-and-else.md).

# If, Else if和Else

#### 1. 条件语句块 (If)

If 是检查特定条件的第一条语句块。如果该条件为真，系统将执行该 If 块内的所有操作。如果为假，系统将跳过并继续向下检查。

#### 2. 补充条件语句块 (Else if)

Else if 总是紧随 If 块之后（或紧随另一个 Else if 之后）。当其上面的条件均为假时，该块会被激活。系统将检查其自身的条件，如果为真，则执行内部的操作，如果为假，则再次跳过。

> 您可以添加多个连续的 Else if 块，以检查脚本的不同情况。

#### 3. 否定语句块 (Else)

Else 是条件链中的最后一个包裹块，不需要配置任何条件。当所有上面的 If 和 Else if 块均为假（没有任何情况满足）时，系统将自动跳入并执行位于 Else 块内的操作。

#### 实际示例：检查账户的登录状态

当您打开一个网页（例如：Facebook, X...）时，个人资料上的账户状态可能会有所不同。您可以使用 If - Else if - Else 的串联来顺利处理所有情况：

* 如果 (If)：看到“创建帖子”按钮（证明账户已登录）。
  * *操作*：进行内容填写并立即发布。
* 否则如果 (Else if)：看到“用户名 / 密码”输入框（账户已注销）。
  * *操作*：从变量中调用数据以填写账户、密码并点击登录。
* 否则全部 (Else)：既没有看到发布按钮，也没有看到登录框（账户可能已被检查点或网络故障）。
  * *操作*：使用 Stop 命令停止程序或截屏以便后续检查。


---

# 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/blocks/if-else-if-and-else.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.
