> 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/mouse/mouse-click-attempt.md).

# 鼠标尝试点击

鼠标尝试点击是鼠标命令组的高级操作，允许脚本对一个目标进行多次重复点击，直到满足某个期望条件才停止。

这个操作是处理网站上“顽固”按钮的完美解决方案（这种按钮有时会延迟，需要点击几次才能生效），或者用于抓取（垃圾邮件）短时间内出现的奖励按钮和礼品盒打开按钮。

#### 核心配置参数：

* 点击类型：与鼠标点击操作类似，您也有3种选择来指定点击位置：
  1. *基于XPath的点击*：系统查找要点击的元素的HTML标签。
  2. *基于当前鼠标指针位置的点击*：在鼠标指针静止的位置连续点击。
  3. *基于坐标的点击*：点击固定的像素点或传递合并坐标的变量，格式为 `900,800`（结合来自 *图像搜索* 操作的结果）。
* 尝试次数：脚本允许执行的最大点击尝试次数（例如输入 `10`，系统将最多点击10次，然后自动停止流程以转到下一个操作，避免脚本无限挂起）。
* 每次点击延迟（秒）：两次连续点击之间的间隔时间，以秒为单位（例如输入 `0.5` 或 `1` 秒，以防鼠标点击过快导致系统误认为是垃圾邮件/DDoS）。
* 停止条件：系统立即停止点击的条件。鼠标将持续点击，直到满足此条件或已达到 *尝试次数* 中规定的点击次数。

#### 实际示例：持续点击“获取OTP码”按钮，直到输入码框出现

当您在加载缓慢的网站上注册账户时，点击“发送码”按钮时，系统可能会阻塞并未立即响应。您需要持续点击鼠标，直到屏幕上出现输入OTP码的框，然后才停止。

* 配置方法：
  * 点击类型：选择 *基于XPath的点击* ➔ 输入发送码按钮的XPath： `//button[@id="send-code"]`。
  * 尝试次数：输入 `5`（最多尝试5次）。
  * 每次点击延迟：输入 `2`（每次点击间隔2秒以等待网页处理）。
  * 停止条件：使用检查元素出现的函数： `hasElement(//input[@id="otp-input"])`。

运行逻辑：系统将鼠标移动到发送码按钮并点击第一次。2秒后，系统检查OTP码输入框（`//input[@id="otp-input"]`）是否出现。如果没有，系统继续点击第二次、第三次……当点击到第三次时，系统响应并且OTP码输入框出现在屏幕上（函数 `hasElement` 返回真），脚本将立即停止此点击操作并转到下一步，而无需再点击剩下的2次。

> 💡 扩展提示：您还可以使用否定条件 `!hasElement(XPATH)` 来指示鼠标持续点击，直到广告横幅或加载图标从屏幕上消失。


---

# 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/mouse/mouse-click-attempt.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.
