> ## Documentation Index
> Fetch the complete documentation index at: https://rpa.bazhuayu.com/helpcenter/llms.txt
> Use this file to discover all available pages before exploring further.

# 循环相似元素(win)

## 指令说明

**描述：** 依次循环窗口中的相似元素，也即是对相同xpath的元素进行循环，再对其每一项元素进行自动化操作。

## 参数说明

<Tabs>
  <Tab title="常规">
    <img src="https://mintcdn.com/bazhuayu-rpa-docs/W742rR5fGwXr1akA/helpcenter/commands/desktop-automation/images/win_loopsimilarelementscommand_1-01.png?fit=max&auto=format&n=W742rR5fGwXr1akA&q=85&s=a556c86cb63d5471a86f4550cade1be7" alt="循环相似元素(win)指令参数面板" width="646" height="410" data-path="helpcenter/commands/desktop-automation/images/win_loopsimilarelementscommand_1-01.png" />

    | 参数           | 说明                                     |
    | ------------ | -------------------------------------- |
    | **选择元素**     | 选择元素库里现有的元素，或捕获新元素：按住Shift键，依次选中两个相似元素 |
    | **输出当前循环位置** | 如果勾选，则会自动输出当前循环项在列表中的位置，从0开始           |
    | **保存当前循环项至** | 指定一个变量名称，用于存储一组相似元素中的当前循环项             |
  </Tab>

  <Tab title="高级">
    <img src="https://mintcdn.com/bazhuayu-rpa-docs/W742rR5fGwXr1akA/helpcenter/commands/desktop-automation/images/win_loopsimilarelementscommand_1-02.png?fit=max&auto=format&n=W742rR5fGwXr1akA&q=85&s=af32be40056b584f9172cc081d42517e" alt="循环相似元素(win)指令参数面板" width="649" height="315" data-path="helpcenter/commands/desktop-automation/images/win_loopsimilarelementscommand_1-02.png" />

    | 参数            | 说明                         |
    | ------------- | -------------------------- |
    | **等待元素存在(s)** | 等待目标元素存在的超时时间              |
    | **倒序循环**      | 如果勾选，将从相似元素的最后一个元素循环到第一个元素 |
  </Tab>
</Tabs>

## 使用示例

<img src="https://mintcdn.com/bazhuayu-rpa-docs/W742rR5fGwXr1akA/helpcenter/commands/desktop-automation/images/win_loopsimilarelementscommand_1-03.png?fit=max&auto=format&n=W742rR5fGwXr1akA&q=85&s=1cc349e1735a6f060112c0fe07e65a42" alt="循环相似元素使用示例 - 流程搭建" width="1234" height="696" data-path="helpcenter/commands/desktop-automation/images/win_loopsimilarelementscommand_1-03.png" />

**该流程执行逻辑：**

【获取窗口对象】获取微信\[搜一搜]窗口

【填写窗口输入框】在微信\[搜一搜]窗口中的输入框输入"深圳大学"并按回车键`{Enter}`

【点击窗口元素】点击"公众号"元素

【点击窗口元素】点击"深圳大学"公众号

【鼠标悬停在窗口元素上】鼠标悬停在当前"深圳大学"公众号窗口上

【滚动鼠标滚轮】滚动鼠标1次

【循环相似元素(win)】循环每一篇文章的标题元素保存到"当前桌面元素"

【获取窗口元素信息】获取"当前桌面元素"的文本信息

【滚动鼠标滚轮】每循环一次鼠标滚动2次

【循环结束标记】循环结束。

### 效果展示

成功循环处理所有相似元素。

<img src="https://mintcdn.com/bazhuayu-rpa-docs/W742rR5fGwXr1akA/helpcenter/commands/desktop-automation/images/win_loopsimilarelementscommand_1-04.png?fit=max&auto=format&n=W742rR5fGwXr1akA&q=85&s=a3afd5705a14d62d13a5845accd6d938" alt="循环相似元素使用示例 - 效果展示" width="1743" height="728" data-path="helpcenter/commands/desktop-automation/images/win_loopsimilarelementscommand_1-04.png" />

<img src="https://mintcdn.com/bazhuayu-rpa-docs/W742rR5fGwXr1akA/helpcenter/commands/desktop-automation/images/win_loopsimilarelementscommand_1-05.gif?s=a3bacd5eb4f93de87f2b509fa58dce7c" alt="循环相似元素(win)使用示例 - 运行结果" width="1886" height="933" data-path="helpcenter/commands/desktop-automation/images/win_loopsimilarelementscommand_1-05.gif" />

<Info>
  使用指令过程中遇到问题？前往 [八爪鱼RPA 开发者社区问答板块](https://rpa.bazhuayu.com/community/questions) 提问，获取官方与社区帮助。
</Info>
