基于图像识别的开源RPA工具,理论上可以支持所有windows软件和网页的自动化

Overview

SimpleRPA

基于图像识别的开源RPA工具,理论上可以支持所有windows软件和网页的自动化

简介

SimpleRPA是一款python语言编写的开源RPA工具(桌面自动控制工具),用户可以通过配置yaml格式的文件,来实现桌面软件的自动化控制,简化繁杂重复的工作,比如运营人员给用户发消息,打标签,给店铺插旗;项目管理人员采集数据;测试人员实现简单的自动化测试等等。

为什么是SimpleRPA

  • 这是一个基于MIT协议的开源项目,对商业应用友好
  • 市面上常见的RPA工具,虽然功能强大完善,但基本上都基于过程控制的理念,实际上成了图形化编程工具,面对稍微复杂的场景,就需要编制大量的判断跳转和子流程嵌套;而SimpleRPA针对实际RPA场景做出了合理的抽象,虽然使用YAML格式配置,实际上是一种桌面自动控制的DSL,可以更便捷地表达自动化场景。
  • 支持配置文件内嵌Python代码,可以实现更灵活的逻辑
  • 基于图像采集、智能匹配和OCR识别,可以支持任何类型的桌面应用,而无需手工分析页面结构。

状态机概念

我们做屏幕自动化任务的时候,通常都会经历这样几个步骤:

  1. 检查当前桌面上是否显示了需要的页面(比如查看特定位置的图像,或者比对OCR识别出的文字)
  2. 如果确实是,就收集一些文字或图像的信息(这一步未必会有,要看具体任务类型,有些自动化只要把页面流程走通就可以)
  3. 查找页面上特定的控件(比如某个按钮),对它进行操作(如点击)
  4. 跳转到下一个页面,回到步骤1,反复循环,直到最终页面出现

SimpleRPA把这个过程,抽象为一个状态机模型:每个页面是一个状态(state),通过“action”触发,可以跳转到下一个状态; 在每一个State内部,可以做check(检查是否需要的页面),可以find(查找特定控件,或者收集信息); 针对find的结果,还可以形成子状态,来实现复杂的操作。

示例

SimpleRPA的自动化脚本,由一个yaml配置文件,和子文件夹构成,文件夹中通常存放要查找的图像模板。

示例1——自动刷新页面

一个简单的配置文件示例如下:

# 有一个特定的浏览器页面,我们需要定时刷新,以便更新它的状态
name: "浏览器自动刷新"
ver: 0.1
# 默认不会调整屏幕分辨率,所有内容里指定的坐标,都是相对于当前屏幕左上角;
# 但如果这里指定了屏幕宽度或高度,就会在开始运行内容之前,调整分辨率
# screen_width: 3440   
# screen_height: 1440
states:
  - name: "当前窗口"
    # 为了简化,这里假设当前桌面刚刚从浏览器窗口切换到脚本运行窗口,所以一启动就先用alt+tab键切换回去
    id: 1
    transition:
      # 通过点击热键这个action, 迁移到下一个状态
      action: hotkey('alt', 'tab')
      wait: 1
  - name: "浏览器窗口"
    id: 2
    check:
      image:
          snapshot: !rect l:0, r:60, t:113, b:182
          template: auto_test/detect_logo.png
          # debug: True
      fail_action: raise_error('当前页面不是期待的页面')
    transition:
      # 通过点击F5实现浏览器刷新,迁移前先等待60s;
      # 没有其他页面需要显示了,所以还是迁移到当前状态,无限循环
      action: hotkey('f5')
      wait: 60
      to: 2

上面这个示例可以用流程图表示如下:

graph TD;
    1[当前窗口] -- Alt+Tab --> 2[浏览器窗口]
    2 -- F5 --> 2 

这里states是一个列表,每个列表项是一个状态,每个状态有一个id属性作为唯一标识。状态之间的迁移,通过transition属性的to来指定。 to指定的内容可以是某一个state的id,也可以是next(缺省值),next意味着迁移到下一个状态(按列表定义顺序,而不是id编号顺序)。

transition的action是表示触发迁移的动作,支持键盘鼠标、屏幕、剪贴板、窗口引用(目前只支持windows)等一系列操作。 transition的wait表示动作执行以后,等待的时间。

这里的check属性里面定义了image,用来检测屏幕上特定区域是否显示了指定的图案,如果图案存在,说明正确进入了当前状态; 如果不存在,会触发fail_action的执行。

示例2——

自动归档trello任务。一个典型的trello归档页面如下: trello看板归档

下面的脚本,可以帮用户自动归档所有已完成的任务。

name: "自动归档Trello"
ver: 0.5
#screen_width: 3440
#screen_height: 1440
range: !rect l:0, r:1920, t:0, b:1080
time_scale: 1
states:
  - name: "点击获取窗口焦点"
    id: 1
    transition:
      # 点击
      action: click(300, 20)
      wait: 1.5
      to: next
  - name: "已完成列表"
    id: 2
    transition:
      # 右击第一个卡片
      action: rightclick(1540, 290)
      wait: 1
      to: next
  - name: "右键菜单"
    id: 3
    find:
      image:
        snapshot: !rect l:1415, r:1805, t:239, b:609
        template: auto_trello/detect_target.png
        confidence: 0.8
      fail_action: raise_error('找不到归档按钮')
    transition:
      # 左击归档按钮
      action: click(1415 + state.find_result.center_x, 239 + state.find_result.center_y)
      wait: 1
      to: 2
      max_time: 2

配置类

实际上,每个配置项,都有对应的数据类型定义,SimpleRPA读取配置文件的时候,会通过objtyping把yaml数据转换为对应的类实例。

数据类型定义,请参照 SimpleRPA 类图

plantuml代理生成的SimpleRPA 类图

本文档开头实例中的配置文件,转换之后的实例关系图如下:SimpleRPA 示例对象图

plantuml代理生成的SimpleRPA 对象图

待实现

  • 更方便的数据读取和采集模型(目前只能基于键盘鼠标操作实现)
  • 图形化设计器(会先放出一个辅助截图工具)
  • 可扩展的操作(这样就可以自己实现
  • 发布到PyPI库,支持pip install 安装
Owner
Song Hui
Song Hui
[BMVC'21] Official PyTorch Implementation of Grounded Situation Recognition with Transformers

Grounded Situation Recognition with Transformers Paper | Model Checkpoint This is the official PyTorch implementation of Grounded Situation Recognitio

Junhyeong Cho 18 Jul 19, 2022
scantailor - Scan Tailor is an interactive post-processing tool for scanned pages.

Scan Tailor - scantailor.org This project is no longer maintained, and has not been maintained for a while. About Scan Tailor is an interactive post-p

1.5k Dec 28, 2022
A python scripts that uses 3 different feature extraction methods such as SIFT, SURF and ORB to find a book in a video clip and project trailer of a movie based on that book, on to it.

A python scripts that uses 3 different feature extraction methods such as SIFT, SURF and ORB to find a book in a video clip and project trailer of a movie based on that book, on to it.

tooraj taraz 3 Feb 10, 2022
keras复现场景文本检测网络CPTN: 《Detecting Text in Natural Image with Connectionist Text Proposal Network》;欢迎试用,关注,并反馈问题...

keras-ctpn [TOC] 说明 预测 训练 例子 4.1 ICDAR2015 4.1.1 带侧边细化 4.1.2 不带带侧边细化 4.1.3 做数据增广-水平翻转 4.2 ICDAR2017 4.3 其它数据集 toDoList 总结 说明 本工程是keras实现的CPTN: Detecti

mick.yi 107 Jan 09, 2023
Can We Find Neurons that Cause Unrealistic Images in Deep Generative Networks?

Can We Find Neurons that Cause Unrealistic Images in Deep Generative Networks? Artifact Detection/Correction - Offcial PyTorch Implementation This rep

CHOI HWAN IL 23 Dec 20, 2022
Program created with opencv that allows you to automatically count your repetitions on several fitness exercises.

Virtual partner of gym Description Program created with opencv that allows you to automatically count your repetitions on several fitness exercises li

1 Jan 04, 2022
Write-ups for the SwissHackingChallenge2021 CTF.

SwissHackingChallenge 2021 : Write-ups This repository contains a collection of my write-ups for challenges solved during the SwissHackingChallenge (S

Julien Béguin 3 Jun 07, 2021
Using computer vision method to recognize and calcutate the features of the architecture.

building-feature-recognition In this repository, we accomplished building feature recognition using traditional/dl-assisted computer vision method. Th

4 Aug 11, 2022
huoyijie 1.2k Dec 29, 2022
Handwritten Text Recognition (HTR) system implemented with TensorFlow (TF) and trained on the IAM off-line HTR dataset. This Neural Network (NN) model recognizes the text contained in the images of segmented words.

Handwritten-Text-Recognition Handwritten Text Recognition (HTR) system implemented with TensorFlow (TF) and trained on the IAM off-line HTR dataset. T

27 Jan 08, 2023
Pure Javascript OCR for more than 100 Languages 📖🎉🖥

Version 2 is now available and under development in the master branch, read a story about v2: Why I refactor tesseract.js v2? Check the support/1.x br

Project Naptha 29.2k Jan 05, 2023
Official implementation of Character Region Awareness for Text Detection (CRAFT)

CRAFT: Character-Region Awareness For Text detection Official Pytorch implementation of CRAFT text detector | Paper | Pretrained Model | Supplementary

Clova AI Research 2.5k Jan 03, 2023
A semi-automatic open-source tool for Layout Analysis and Region EXtraction on early printed books.

LAREX LAREX is a semi-automatic open-source tool for layout analysis on early printed books. It uses a rule based connected components approach which

162 Jan 05, 2023
Automatically fishes for you while you are afk :)

Dank-memer-afk-script A simple and quick way to make easy money in Dank Memer! How to use Open a discord channel which has the Dank Memer bot enabled.

Pranav Doshi 9 Nov 11, 2022
Demo processor to illustrate OCR-D Python API

ocrd_vandalize/ Demo processor to illustrate the OCR-D/core Python API Description :TODO: write docs :) Installation From PyPI pip3 install ocrd_vanda

Konstantin Baierer 5 May 05, 2022
DouZero is a reinforcement learning framework for DouDizhu - 斗地主AI

[ICML 2021] DouZero: Mastering DouDizhu with Self-Play Deep Reinforcement Learning | 斗地主AI

Kwai 3.1k Jan 05, 2023
Multi-choice answer sheet correction system using computer vision with opencv & python.

Multi choice answer correction 🔴 5 answer sheet samples with a specific solution for detecting answers and sheet correction. 🔴 By running the soluti

Reza Firouzi 7 Mar 07, 2022
(CVPR 2021) Back-tracing Representative Points for Voting-based 3D Object Detection in Point Clouds

BRNet Introduction This is a release of the code of our paper Back-tracing Representative Points for Voting-based 3D Object Detection in Point Clouds,

86 Oct 05, 2022
This is a GUI for scrapping PDFs with the help of optical character recognition making easier than ever to scrape PDFs.

pdf-scraper-with-ocr With this tool I am aiming to facilitate the work of those who need to scrape PDFs either by hand or using tools that doesn't imp

Jacobo José Guijarro Villalba 75 Oct 21, 2022
Tesseract Open Source OCR Engine (main repository)

Tesseract OCR About This package contains an OCR engine - libtesseract and a command line program - tesseract. Tesseract 4 adds a new neural net (LSTM

48.4k Jan 09, 2023