activities
latest
false
重要 :
请注意,此内容已使用机器翻译进行了部分本地化。 新发布内容的本地化可能需要 1-2 周的时间才能完成。
UiPath logo, featuring letters U and I in white

用户界面自动化活动

上次更新日期 2025年11月12日

使用 OCR 与图像自动化的示例

由于在虚拟环境中很难实现自动化,OCR 和图像自动化通常要同时进行,因此我们创建了一个自动化,它可从扫描的发票中检索员工的电子邮件和发票号。然后,该自动化将信息输入虚拟机上的虚拟费用应用程序 (ExpenseIt),并将发票总额与应用程序中的总额进行比较:

  1. 创建新序列
  2. 打开扫描的发票,示例中使用的发票可从此处下载。出于兼容性原因,我们建议使用 Adobe Acrobat Reader。
  3. As explained Relative Scraping, scrape the employee’s email by using OCR technology. A container, Attach Window renamed in this example to Attach PDF, that holds the selector and lets all the other activities know where to perform actions is generated. In it, there are a Find Image, that selects the anchor for relative scraping, a Get OCR Text that retrieves the email address of the employee, and two Set Clipping Region activities: one to translate the first clipping region to the second one, and the other to reset the clipping region.
  4. 变量面板中,创建一个名为 email 的新泛型值变量。
  5. 在以前生成的获取 OCR 文本活动的文本属性中输入电子邮件变量。
  6. 把上面的序列命名为“阅读电子邮件”


    注意:UiPath Studio 提供的 OCR 引擎各有优点和缺点,使用哪个 OCR 引擎依环境而定,关键在于测试在每种情况下哪个引擎性能更出色。针对不同任务更换 OCR 引擎可使效果更好。
  7. As explained in Relative Scraping, scrape the invoice number by using OCR technology. The recorder generates a container, Attach Window renamed in this example to Attach PDF, that holds the selector and lets all the other activities know where to perform actions. Inside the container, there are a Find Image, that selects the anchor for relative scraping, a Get OCR Text that retrieves the invoice number of the employee, and two Set Clipping Region activities, one to translate the first clipping region to the second one, and one to reset the clipping region.
  8. “变量面板”中,创建一个名为 invoiceNo新“泛型值”变量。
  9. 在以前生成的获取 OCR 文本活动的文本属性中输入 invoiceNo 变量。
  10. 把上面的序列命名为“读取发票编号”


  11. As explained Relative Scraping, scrape the employee’s total expenses by using OCR technology. The recorder generates a container, Attach PDF, that holds the selector and lets all the other activities know where to perform actions. Inside it, there are a Find Image, that selects the anchor for relative scraping, a Get OCR Text that retrieves the total expenses of the employee, and two Set Clipping Region activities, one to translate the first clipping region to the second one, and one to reset the clipping region.
  12. “变量面板”中,创建一个名为 totalValue 的新“泛型值”变量。
  13. 在以前生成的获取 OCR 文本活动的文本属性中输入 totalValue 变量。
  14. 把上面的序列命名为“读取总费用”


    注意:在虚拟机环境中打开应用程序时,最佳实践是为要在计算机桌面上打开的应用程序创建一个快捷方式,并为其分配一个热键。尝试使用“单击 OCR 文本”来单击应用程序的图标时,有时可能会由于背景颜色或所选图标的变化而失败。
  15. 在虚拟机桌面上创建 ExpenseIt 应用程序的快捷方式。
  16. 右击快捷方式并从上下文菜单中选择属性。系统将显示快捷方式属性窗口。
  17. 快捷方式选项卡上的快捷键字段中,按下要使用的键(例如 Alt+Ctrl+T),从而为应用程序分配一个热键。


  18. 打开“Citrix 录制向导”,启动一个新录制会话。
  19. 录制将先前分配给应用程序快捷方式的热键发送给虚拟机窗口的操作。
  20. 使用“ 相对抓取 ” 根据标签的位置单击 ExpenseIt 应用程序中的“电子邮件” 字段。
  21. ExpenseIt 应用程序的电子邮件字段中,输入 email 变量。
  22. 使用相对抓取可根据“员工数量”标签的位置单击 ExpenseIt 应用程序中的员工数量字段。
  23. ExpenseIt 应用程序的员工数量字段中添加 invoiceNo 变量。
  24. “录制向导”中单击“保存并退出”。录制器生成一个“附加窗口”容器,用于放置选取器,并让所有其他活动知道要执行操作的位置。该容器包含“发送热键”活动、“单击图像”活动(单击“电子邮件”标签右侧字段)、“键入”活动(在字段中键入电子邮件变量)、“单击图像”活动(单击“员工编号”标签右侧字段)和“键入”活动(在字段中键入 invoiceNo 变量)。


  25. 打开“Citrix 录制向导”,启动一个新录制会话。
  26. 录制在 ExpenseIt 应用程序中单击“创建费用报告”按钮的操作。
  27. 使用相对抓取来抓取与总费用 ($) 标签对应的值。
  28. “录制向导”中单击“保存并退出”。录制器生成一个“附加窗口”容器,用于放置选取器,并让所有其他活动知道要执行操作的位置。该容器包含“单击 OCR 文本”活动(将单击“创建费用报告”按钮)、“查找图像”活动(设置相对提取的锚点)、“获取 OCR 文本”活动(检索总费用值)和两个“设置剪切区域”活动(一个活动可将第一个剪切区域转换为第二个剪切区域,另一个活动可重置剪切区域)。


  29. “变量面板”中,创建一个名为 totalExpense新“泛型值”变量。
  30. 在以前生成的获取 OCR 文本活动的文本属性字段中输入 totalExpense 变量。
  31. “If 条件”活动拖动到最后生成的录制序列的后面。
  32. If 条件活动的“条件”属性设置为 totalExpense = totalValue。这意味着自动化会检查发票的总价值是否等于费用应用程序中的值。
  33. 消息框活动拖到 If 条件活动的 Then 部分。
  34. 消息框文本属性字段中,编写一条消息来声明值相等,因此发票无误。
  35. 消息框活动拖到 If 条件活动的 Else 部分。
  36. 消息框文本属性字段中,编写一条消息来声明值不相等,因此发票有误。


  37. Press F5 to run the automation. Note that the automation inputs the employee data from the scanned invoice into the ExpenseIt application, compares the total value of the invoice with the total expenses registered, and informs the user if the values are equal or not.

由于这种自动化需要连接到虚拟机,所以没有必要上传原始项目,因为原始项目不能在另一台计算机上工作。我们鼓励您按照上述步骤构建您自己的项目。

此页面有帮助吗?

获取您需要的帮助
了解 RPA - 自动化课程
UiPath Community 论坛
Uipath Logo
信任与安全
© 2005-2025 UiPath。保留所有权利。