{"id":13814334,"url":"https://github.com/yihleego/robotic-process-automation","last_synced_at":"2025-04-09T10:06:08.647Z","repository":{"id":40410965,"uuid":"465689248","full_name":"yihleego/robotic-process-automation","owner":"yihleego","description":"🤖 Robotic process automation (RPA) for WeChat, WeCom, etc. Support multiple clients and keep the computer unlocked when disconnect from the remote desktop.","archived":false,"fork":false,"pushed_at":"2024-06-03T09:27:50.000Z","size":37542,"stargazers_count":236,"open_issues_count":6,"forks_count":55,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-04-01T22:18:33.593Z","etag":null,"topics":["auto","automation","robot","robotic-process-automation","rpa","task","wechat","wecom"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yihleego.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-03-03T11:22:07.000Z","updated_at":"2025-03-26T15:26:23.000Z","dependencies_parsed_at":"2024-08-04T04:05:39.400Z","dependency_job_id":"871ebf15-ec0f-4762-9142-b8ee2c673af9","html_url":"https://github.com/yihleego/robotic-process-automation","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yihleego%2Frobotic-process-automation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yihleego%2Frobotic-process-automation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yihleego%2Frobotic-process-automation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yihleego%2Frobotic-process-automation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yihleego","download_url":"https://codeload.github.com/yihleego/robotic-process-automation/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248018060,"owners_count":21034048,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["auto","automation","robot","robotic-process-automation","rpa","task","wechat","wecom"],"created_at":"2024-08-04T04:01:53.816Z","updated_at":"2025-04-09T10:06:08.621Z","avatar_url":"https://github.com/yihleego.png","language":"Java","funding_links":[],"categories":["Java"],"sub_categories":[],"readme":"# Robotic Process Automation\n\n机器人流程自动化 (RPA)，像人类工作者一样，通过跨各种应用程序运行的软件或硬件系统实现任务自动化。软件或机器人可以学习具有多个步骤和应用程序的工作流程，例如获取收到的表格、发送回执消息、检查表格的完整性、将表格归档到文件夹中以及使用表格名称更新电子表格，提交日期等。RPA软件旨在减轻员工完成重复性简单任务的负担。\n\n## Usage\n\n### 客户端自动化使用介绍\n\n请确保本地计算机已安装对应客户端，且`rpa-client`与`rpa-server`均已启动。\n\n当前系统支持以下客户端：\n\n|  AppId   | Name |\n|:--------:|:----:|\n|  wechat  |  微信  |\n|  wecom   | 企业微信 |\n|    qq    | 腾讯QQ |\n|   tim    | TIM  |\n| dingtalk |  钉钉  |\n|   lark   |  飞书  |\n\n由于任务必须通过指定用户去执行，所以在执行任务之前，需要确保用户存在。\n\n#### 1. 创建用户\n\n##### 通过HTTP接口创建用户\n\n- 接口：`http://\u003chost\u003e:\u003cport\u003e/users`\n- 方法：`POST`\n- 格式：`JSON`\n- 参数：`Body`\n\n| Property   | Type   | Required | Description         |\n|:-----------|:-------|:---------|:--------------------|\n| users      | User[] | 必填       | 用户对象数组。             |\n| └ id       | String | 可选       | 用户ID。为空时服务端会自动生成ID。 |\n| └ appId    | String | 必填       | 关联AppID。            |\n| └ account  | String | 必填       | 用户账号，用于匹配客户端。       |\n| └ nickname | String | 可选       | 用户昵称，用于展示。          |\n| └ realname | String | 可选       | 用户真实名称，用于展示。        |\n| └ company  | String | 可选       | 用户所属公司名称，用于展示。      |\n\n\u003e 注意，`企业微信`客户端中无法直接获取当前登录人的`account`，当前是通过`${realname}_${company}`组合匹配客户端。\n\n接口示例：\n\n```shell\ncurl -X POST --location \"http://localhost:8080/users\" \\\n    -H \"Content-Type: application/json\" \\\n    -d \"{\n          \\\"users\\\": [\n            {\n              \\\"id\\\": \\\"uid\\\",\n              \\\"appId\\\": \\\"wechat\\\",\n              \\\"account\\\": \\\"account\\\",\n              \\\"nickname\\\": \\\"nickname\\\"\n            }\n          ]\n        }\"\n```\n\n##### 通过SQL脚本创建用户\n\n```sql\ninsert into user (id, app_id, account, nickname, realname, company, status, created_time, updated_time)\nvalues ('uid', 'wechat', 'account', 'nickname', 'realname', 'company', 1, now(), null);\n```\n\n#### 2. 创建任务\n\n##### 通过HTTP接口创建任务\n\n- 接口：`http://\u003chost\u003e:\u003cport\u003e/tasks`\n- 方法：`POST`\n- 格式：`JSON`\n- 参数：`Body`\n\n| Property       | Type     | Required | Description                                |\n|:---------------|:---------|:---------|:-------------------------------------------|\n| tasks          | Task[]   | 必填       | 任务对象数组。                                    |\n| └ id           | String   | 可选       | 任务ID。为空时服务端会自动生成ID。                        |\n| └ userId       | String   | 必填       | 关联用户ID。                                    |\n| └ type         | String   | 必填       | 任务类型，参考[任务类型字典表](TASKTYPES.md)。            |\n| └ priority     | Integer  | 可选       | 任务优先级，值越小越优先。为空时取默认配置的优先级。                 |\n| └ data         | String   | 可选       | 任务数据，格式为`JSON`字符串。                         |\n| └ scheduleTime | DateTime | 可选       | 任务执行时间，例如：`2022-01-01 10:00:00`。为空时会被立即执行。 |\n\n示例：\n\n```shell\ncurl -X PATCH --location \"http://localhost:8080/tasks\" \\\n    -H \"Content-Type: application/json\" \\\n    -d \"{\n          \\\"tasks\\\": [\n            {\n              \\\"id\\\": \\\"tid\\\",\n              \\\"userId\\\": \\\"uid\\\",\n              \\\"type\\\": \\\"login\\\",\n              \\\"priority\\\": \\\"0\\\",\n              \\\"data\\\": \\\"\\\",\n              \\\"scheduleTime\\\": \\\"2022-01-01 10:00:00\\\",\n            }\n          ]\n        }\"\n```\n\n##### 通过SQL脚本创建任务\n\n```sql\ninsert into task (id, user_id, app_id, type, priority, data, status, created_time, updated_time, schedule_time)\nvalues ('tid', 'uid', 'wechat', 'login', 0, null, 0, now(), null, '2022-01-01 10:00:00');\n```\n\n### 微信客户端自动化\n\n服务端提供了一个运行时的测试页面，开发者可以用它在本地测试简单任务。\n打开浏览器访问`http://\u003chost\u003e:\u003cport\u003e/index.html`，然后选择待测试的客户端即可。\n\n#### 微信客户端登录任务\n\n*登录客户端不需要参数*\n\n![task_wechat_login](images/task_wechat_login.gif)\n\n#### 微信客户端登出任务\n\n*登出客户端不需要参数*\n\n![task_wechat_logout](images/task_wechat_logout.gif)\n\n#### 微信客户端发送个人消息任务\n\n参数格式：\n\n| Property  | Type      | Required | Description     |\n|:----------|:----------|:---------|:----------------|\n| target    | String    | 必填       | 发送对象。           |\n| messages  | Message[] | 必填       | 消息对象数组。         |\n| └ type    | String    | 必填       | 消息类型。           |\n| └ content | String    | 必填       | 消息内容，文本内容或文件地址。 |\n\n消息类型：\n\n| Code    | Name    | Description |\n|:--------|:--------|:------------|\n| text    | TEXT    | 文本          |\n| image   | IMAGE   | 图片          |\n| video   | VIDEO   | 视频          |\n| file    | FILE    | 文件          |\n\n参数示例：\n\n```json\n{\n  \"target\": \"friend\",\n  \"messages\": [\n    {\n      \"type\": \"text\",\n      \"content\": \"message\"\n    },\n    {\n      \"type\": \"image\",\n      \"content\": \"https://rpa.leego.io/image.png\"\n    },\n    {\n      \"type\": \"video\",\n      \"content\": \"https://rpa.leego.io/video.mp4\"\n    },\n    {\n      \"type\": \"file\",\n      \"content\": \"https://rpa.leego.io/file.zip\"\n    }\n  ]\n}\n```\n\n![task_wechat_send_private_messages](images/task_wechat_send_private_messages.gif)\n\n#### 微信客户端发送群消息任务\n\n参数格式：\n\n| Property  | Type      | Required | Description     |\n|:----------|:----------|:---------|:----------------|\n| target    | String    | 必填       | 群名称。            |\n| messages  | Message[] | 必填       | 消息对象数组。         |\n| └ type    | String    | 必填       | 消息类型。           |\n| └ content | String    | 必填       | 消息内容，文本内容或文件地址。 |\n\n消息类型：\n\n| Code    | Name    | Description |\n|:--------|:--------|:------------|\n| text    | TEXT    | 文本          |\n| image   | IMAGE   | 图片          |\n| video   | VIDEO   | 视频          |\n| file    | FILE    | 文件          |\n| mention | MENTION | 提醒          |\n\n参数示例：\n\n```json\n{\n  \"target\": \"group\",\n  \"messages\": [\n    {\n      \"type\": \"text\",\n      \"content\": \"message\"\n    },\n    {\n      \"type\": \"image\",\n      \"content\": \"https://rpa.leego.io/image.png\"\n    },\n    {\n      \"type\": \"video\",\n      \"content\": \"https://rpa.leego.io/video.mp4\"\n    },\n    {\n      \"type\": \"file\",\n      \"content\": \"https://rpa.leego.io/file.zip\"\n    },\n    {\n      \"type\": \"mention\",\n      \"content\": \"member\"\n    }\n  ]\n}\n```\n\n![task_wechat_send_group_messages](images/task_wechat_send_group_messages.gif)\n\n### 企业微信客户端自动化\n\n#### 企业微信客户端登录任务\n\n*登录客户端不需要参数*\n\n![task_wecom_login](images/task_wecom_login.gif)\n\n#### 企业微信客户端登出任务\n\n*登出客户端不需要参数*\n\n![task_wecom_logout](images/task_wecom_logout.gif)\n\n#### 企业微信客户端发送个人消息任务\n\n参数格式：\n\n| Property  | Type      | Required | Description     |\n|:----------|:----------|:---------|:----------------|\n| target    | String    | 必填       | 发送对象。           |\n| messages  | Message[] | 必填       | 消息对象数组。         |\n| └ type    | String    | 必填       | 消息类型。           |\n| └ content | String    | 必填       | 消息内容，文本内容或文件地址。 |\n\n消息类型：\n\n| Code    | Name    | Description |\n|:--------|:--------|:------------|\n| text    | TEXT    | 文本          |\n| image   | IMAGE   | 图片          |\n| video   | VIDEO   | 视频          |\n| file    | FILE    | 文件          |\n\n参数示例：\n\n```json\n{\n  \"target\": \"friend\",\n  \"messages\": [\n    {\n      \"type\": \"text\",\n      \"content\": \"message\"\n    },\n    {\n      \"type\": \"image\",\n      \"content\": \"https://rpa.leego.io/image.png\"\n    },\n    {\n      \"type\": \"video\",\n      \"content\": \"https://rpa.leego.io/video.mp4\"\n    },\n    {\n      \"type\": \"file\",\n      \"content\": \"https://rpa.leego.io/file.zip\"\n    }\n  ]\n}\n```\n\n![task_wecom_send_private_messages](images/task_wecom_send_private_messages.gif)\n\n#### 企业微信客户端发送群消息任务\n\n参数格式：\n\n| Property  | Type      | Required | Description     |\n|:----------|:----------|:---------|:----------------|\n| target    | String    | 必填       | 群名称。            |\n| messages  | Message[] | 必填       | 消息对象数组。         |\n| └ type    | String    | 必填       | 消息类型。           |\n| └ content | String    | 必填       | 消息内容，文本内容或文件地址。 |\n\n消息类型：\n\n| Code    | Name    | Description |\n|:--------|:--------|:------------|\n| text    | TEXT    | 文本          |\n| image   | IMAGE   | 图片          |\n| video   | VIDEO   | 视频          |\n| file    | FILE    | 文件          |\n| mention | MENTION | 提醒          |\n\n参数示例：\n\n```json\n{\n  \"target\": \"group\",\n  \"messages\": [\n    {\n      \"type\": \"text\",\n      \"content\": \"message\"\n    },\n    {\n      \"type\": \"image\",\n      \"content\": \"https://rpa.leego.io/image.png\"\n    },\n    {\n      \"type\": \"video\",\n      \"content\": \"https://rpa.leego.io/video.mp4\"\n    },\n    {\n      \"type\": \"file\",\n      \"content\": \"https://rpa.leego.io/file.zip\"\n    },\n    {\n      \"type\": \"mention\",\n      \"content\": \"member\"\n    }\n  ]\n}\n```\n\n![task_wecom_send_group_messages](images/task_wecom_send_group_messages.gif)\n\n#### 微信客户端添加联系人任务\n\n参数格式：\n\n| Property | Type      | Required | Description |\n|:---------|:----------|:---------|:------------|\n| target   | String    | 必填       | 群名称。        |\n| contacts | Contact[] | 必填       | 联系人对象数组。    |\n| └ target | String    | 必填       | 用户手机号码或邮箱。  |\n| └ reason | String    | 可选       | 添加联系人备注。    |\n\n参数示例：\n\n```json\n{\n  \"contacts\": [\n    {\"target\": \"phone\"},\n    {\"target\": \"email\", \"reason\": \"reason\"}\n  ]\n}\n```\n\n*过于先进，不宜展示。*\n\n## Documentation\n\n### 通过关闭互斥体实现多客户端运行\n\n为了防止客户端被多次启动，开发者们通常会使用创建互斥体（Mutex）对象的方式进行实现。互斥锁是一种用于多线程编程中，保护共享资源不被多个线程或进程同时访问的机制。\n\n#### Windows 中创建或打开互斥对象\n\n##### CreateMutexA function (synchapi.h)\n\n```cpp\nHANDLE CreateMutexA(\n  [in, optional] LPSECURITY_ATTRIBUTES lpMutexAttributes,\n  [in]           BOOL                  bInitialOwner,\n  [in, optional] LPCSTR                lpName\n);\n```\n\n##### 参数\n\n`[in, optional] lpMutexAttributes`\n\n指向 [SECURITY_ATTRIBUTES] 结构的指针。如果此参数为`NULL`，则句柄不能被子进程继承。\n\n结构的`lpSecurityDescriptor`成员指定新互斥体的安全描述符。如果`lpMutexAttributes`为`NULL`，则互斥锁将获得默认的安全描述符。互斥锁的默认安全描述符中的`ACL`来自创建者的主要或模拟令牌。\n\n`[in] bInitialOwner`\n\n如果此值为`TRUE`并且调用者创建了互斥锁，则调用线程将获得互斥锁对象的初始所有权。否则，调用线程不会获得互斥锁的所有权。要确定调用者是否创建了互斥锁，请参阅返回值部分。\n\n`[in, optional] lpName`\n\n互斥对象的名称。该名称仅限于`MAX_PATH`个字符。名称比较区分大小写。\n\n如果`lpName`与现有的命名互斥对象的名称匹配，则此函数请求`MUTEX_ALL_ACCESS`访问权限。在这种情况下，将忽略`bInitialOwner`参数，因为它已由创建过程设置。如果`lpMutexAttributes`参数不为NULL，它决定句柄是否可以被继承，但它的安全描述符成员被忽略。\n\n如果`lpName`为`NULL`，则创建互斥对象时没有名称。\n\n如果`lpName`与现有事件、信号量、可等待计时器、作业或文件映射对象的名称匹配，则该函数将失败并且 [GetLastError] 函数返回`ERROR_INVALID_HANDLE`。这是因为这些对象共享相同的命名空间。\n\n该名称可以具有“全局”或“本地”前缀，以在全局或会话命名空间中显式创建对象。名称的其余部分可以包含除反斜杠字符 (\\) 之外的任何字符。有关详细信息，请参阅 内核对象命名空间。使用终端服务会话实现快速用户切换。内核对象名称必须遵循为终端服务概述的准则，以便应用程序可以支持多个用户。\n\n该对象可以在私有命名空间中创建。有关详细信息，请参阅对象命名空间。\n\n##### 返回值\n\n如果函数成功，则返回值是新创建的互斥对象的句柄（Handle）。\n\n如果函数失败，则返回值为`NULL`。要获取扩展的错误信息，请调用 [GetLastError] 函数。\n\n如果互斥锁是一个命名互斥锁并且该对象在此函数调用之前存在，则返回值是现有对象的句柄，并且 [GetLastError] 函数返回`ERROR_ALREADY_EXISTS`。\n\n#### 通过句柄关闭互斥体\n\n##### 使用 Process Explorer\n\nProcess Explorer 是 Microsoft 官方提供的用于找出进程已打开或加载的`Handle`和`DLL`信息的工具。\n\nProcess Explorer 官方页面：https://docs.microsoft.com/en-us/sysinternals/downloads/process-explorer\n\n示例：\n\n1. 以 WeChat 为例，首先启动 WeChat，在 [Process Explorer] 主界面中找到名为`WeChat.exe`进程并选中。\n\n2. 然后在`Lower Pane`界面中找到`Type`为`Mutant`且`Name`为`\\Sessions\\1\\BaseNamedObjects\\_WeChat_App_Instance_Identity_Mutex_Name`的`Handle`。\n\n3. 右键单击`Close Handle`关闭句柄后，即可启动一个新进程。\n\n![process_explorer_wechat_1](images/process_explorer_wechat_1.png)\n\n![process_explorer_wechat_2](images/process_explorer_wechat_2.png)\n\n##### Python代码实现\n\n```python\nhandles = handler.find_handles(process_ids=[10000], handle_names=[r'\\Sessions\\1\\BaseNamedObjects\\_WeChat_App_Instance_Identity_Mutex_Name'])\nhandler.close_handles(handles)\n```\n\n参考源码：[client/handler/handler.py](/rpa-client/handler/handler.py)\n\n[SECURITY_ATTRIBUTES]: https://docs.microsoft.com/en-us/previous-versions/windows/desktop/legacy/aa379560(v=vs.85)\n\n[GetLastError]: https://docs.microsoft.com/en-us/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror\n\n[Process Explorer]: https://docs.microsoft.com/en-us/sysinternals/downloads/process-explorer\n\n### 通过`tscon`保持Windows远程桌面关闭后仍可交互的方法\n\n使用远程桌面连接到远程计算机时，关闭远程桌面会锁定计算机并显示登录屏幕。在锁定模式下，计算机没有`GUI`，因此任何当前运行或计划的`GUI`测试都将失败。\n\n为避免`GUI`测试出现问题，可以使用`tscon`实用程序断开与远程桌面的连接。`tscon`将控制权返回到远程计算机上的原始本地会话，绕过登录屏幕。远程计算机上的所有程序继续正常运行，包括`GUI`测试。\n\n#### 什么是`tscon`？\n\n`tscon`是Windows系统提供的可用于连接到远程桌面会话主机服务器上的另一个会话的工具。\n\n#### 如何使用`tscon`？\n\n```shell\ntscon {\u003csessionID\u003e | \u003csessionname\u003e} [/dest:\u003csessionname\u003e] [/password:\u003cpw\u003e | /password:*] [/v]\n```\n\n| 参数                    | 描述                                                       |\n|:----------------------|:---------------------------------------------------------|\n| `\u003csessionID\u003e`         | 指定要连接的会话的ID。如果使用可选`/dest:\u003csessionname\u003e`参数，也可以指定当前会话的名称。  |\n| `\u003csessionname\u003e`       | 指定要连接的会话的名称。                                             |\n| /dest:`\u003csessionname\u003e` | 指定当前会话的名称。当您连接到新会话时，此会话将断开连接。您还可以使用此参数将另一个用户的会话连接到不同的会话。 |\n| /password:`\u003cpw\u003e`      | 指定拥有要连接到的会话的用户的密码。当连接用户不拥有会话时，需要此密码。                     |\n| /password:`*`         | 提示拥有您要连接的会话的用户的密码。                                       |\n| /v                    | 显示有关正在执行的操作的信息。                                          |\n| /?                    | 在命令提示符处显示帮助。                                             |\n\n##### 手动断开远程\n\n要从远程桌面断开连接，请以管理员身份在远程计算机上（在远程桌面连接窗口中）运行以下命令，例如，通过命令行：\n\n```shell\n%windir%\\System32\\tscon.exe RDP-Tcp### NNN /dest:console\n```\n\n其中`RDP-Tcp### NNN`是当前远程桌面会话的`ID`，例如`RDP-Tcp#5`。您可以在**Windows任务管理器**的“**用户**”选项卡上的“**会话**”列中看到它。\n\n![Windows Task Manager](images/windows_task_manager_rdp.png)\n\n您将看到您的远程桌面服务会话已结束消息，并且远程桌面客户端将关闭。但远程计算机上的所有程序和测试将继续正常运行。\n\n提示：会话列默认隐藏。要显示它，请右键单击显示 CPU、内存等的行中的某处，然后在打开的上下文菜单中选择会话。\n\n##### 通过批处理文件断开连接\n\n您可以使用批处理文件自动执行断开过程。在远程计算机上，执行以下操作：\n\n1. 使用以下代码创建一个批处理文件：\n\n```shell\nfor /f \"skip=1 tokens=3\" %%s in ('query user %USERNAME%') do (\n  %windir%\\System32\\tscon.exe %%s /dest:console\n)\n```\n\n2. 创建此文件的桌面快捷方式。为此，请右键单击批处理文件并选择发送到 \u003e 桌面（创建快捷方式）。\n3. 在快捷方式属性中，单击高级并选择以管理员身份运行。\n4. 在远程计算机上双击此快捷方式（在远程桌面连接窗口中）或在测试开始时调用此批处理文件（前提是测试以管理员身份运行）。\n\n#### 注意事项\n\n- `tscon`使远程计算机保持解锁状态，这会降低系统安全性。测试运行结束后，您可以使用以下命令锁定计算机：\n\n    ```shell\n    Rundll32.exe user32.dll, LockWorkStation\n    ```\n\n- 如果远程计算机上正在运行`rdpclip.exe`进程，并且当您从远程会话断开连接时剪贴板不为空，则`rdpclip.exe`进程可能会失败。\n\n  为避免此问题，您可以在断开会话之前终止`rdpclip.exe`进程。\n\n#### 参考链接\n\n- https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/tscon\n- https://support.smartbear.com/testcomplete/docs/testing-with/running/via-rdp/keeping-computer-unlocked.html\n\n### 功能拓展\n\n若需要拓展自动化功能或兼容不同版本的客户端，您可以在 [rpa-client/app](/rpa-client/apps) 模块中新增或编辑任务脚本。\n\n项目中主要使用以下两种方式实现：\n\n1. [pywinauto](https://github.com/pywinauto/pywinauto)\n\n   是用于 Microsoft Windows GUI 自动化 的 python 模块。在最简单的情况下，它允许您将鼠标和键盘操作发送到 Windows 对话框和控件，但它支持更复杂的操作，例如获取文本数据。\n\n3. [Airtest](https://github.com/AirtestProject/Airtest)\n\n   是由网易游戏推出的一个跨平台的、基于图像识别的UI自动化测试框架，适用于游戏和App，支持平台有Windows、Android和iOS。\n\n## Deployment\n\n### RPA客户端部署\n\n请确保使用的操作系统为 Windows 7 及以上，Python 的版本为3.7.0及以上。\n\n#### 下载并安装客户端\n\n需要注意 airtest 目前版本依赖`pywinauto==0.6.3`，当前项目需要`pywinauto==0.6.8`，在安装依赖时请加上`--no-deps`参数，或者在安装完依赖后手动执行一遍`pip install pywinauto==0.6.8`。\n\n```bash\ngit clone https://github.com/yihleego/robotic-process-automation.git\ncd robotic-process-automation/rpa-client\npip install --no-deps -r requirements.txt\n```\n\n#### 配置客户端\n\n客户端配置文件位于 [rpa-client/config.yml](rpa-client/config.yml)，开发者可以根据实际场景修改配置。\n\n| Property            | Description | Default               |\n|:--------------------|:------------|:----------------------|\n| server.host         | 服务器主机       | localhost             |\n| server.port         | 服务器端口       | 18888                 |\n| server.path         | 服务器路径       | /rpa                  |\n| server.ssl          | 是否启用SSL     | False                 |\n| app.size            | 程序最大可运行数量   | 32                    |\n| app.path.`\u003cappid\u003e`  | 自定义程序路径     | *从注册表中获取*             |\n| airtest.cvstrategy  | 图像识别算法      | [ tpl,sift,brisk ]    |\n| airtest.timeout     | 图像识别算法      | 20秒                   |\n| airtest.timeout-tmp | 图像识别算法      | 3秒                    |\n| logging.level       | 日志级别        | DEBUG                 |\n| logging.format      | 日志格式        | *默认格式*                |\n| logging.filename    | 日志文件名       | ./logs/rpa-client.log |\n\n#### 启动客户端\n\n运行 [rpa-client/main.py](rpa-client/main.py) 即可。\n\n### RPA服务端部署\n\n请确保使用的 Java 的版本为17及以上，服务运行时依赖 MySQL 和 Redis，请务必在部署服务前安装并启动它们。\n\n#### 下载并安装服务端\n\n```bash\ngit clone https://github.com/yihleego/robotic-process-automation.git\ncd robotic-process-automation/rpa-server\nmvn clean install\n```\n\n#### 配置服务端\n\n##### 必填配置\n\n| Property                            | Description | Default                         |\n|:------------------------------------|:------------|:--------------------------------|\n| spring.datasource.driver-class-name | 数据源驱动       | com.mysql.cj.jdbc.Driver        |\n| spring.datasource.url               | 数据源URL      | jdbc:mysql://localhost:3306/rpa |\n| spring.datasource.username          | 数据源用户名      |                                 |\n| spring.datasource.password          | 数据源密码       |                                 |\n| spring.data.redis.host              | Redis主机     | localhost                       |\n| spring.data.redis.port              | Redis端口     | 6379                            |\n| spring.data.redis.password          | Redis密码     |                                 |\n| spring.data.redis.database          | Redis数据库    | 0                               |\n\n上述配置可于 [application.properties](rpa-server/src/main/resources/application.properties) 文件中修改。\n\n##### 可选配置\n\n| Property                        | Description       | Default                          |\n|:--------------------------------|:------------------|:---------------------------------|\n| rpa.websocket.port              | WebSocket服务端口     | 18888                            |\n| rpa.websocket.path              | WebSocket服务路径     | /rpa                             |\n| rpa.websocket.idle-timeout      | WebSocket服务空闲超时时间 | 5m                               |\n| rpa.converter.date-time-pattern | 全局日期时间格式          | yyyy-MM-dd HH:mm:ss              |\n| rpa.converter.date-pattern      | 全局器日期格式           | yyyy-MM-dd                       |\n| rpa.converter.time-pattern      | 全局时间格式            | HH:mm:ss                         |\n| rpa.client.cache-key            | 客户端缓存键格式          | rpa:client:`\u003cappid\u003e`:`\u003caccount\u003e` |\n| rpa.client.cache-timeout        | 客户端缓存超时时间         | 5m                               |\n\n详情请见 [RpaProperties](rpa-server/src/main/java/io/leego/rpa/config/RpaProperties.java)。\n\n#### 启动服务端\n\n启动服务前，请先在`MySQL`实例中执行以下脚本\n\n- [rpa_ddl.sql](rpa-server/sql/rpa_ddl.sql)\n- [rpa_dml.sql](rpa-server/sql/rpa_dml.sql)\n\n运行 [RpaApplication.java](rpa-server/src/main/java/io/leego/rpa/RpaApplication.java) 即可。\n\n## Q\u0026A\n\n### UiaApp 和 AirApp 的区别 \n\n- UiaApp：基于 UIA 实现的程序，通过 UI 组件的 ID、Name、Class 等定位对应的元素，然后对其进行操作，\n  类似 HTML 的 DOM 树，可以通过选择器定位元素和操作，例如: `$(\".btn\").click();`。\n- AirApp：是基于图像识别实现。\n\n判断一个应用是否支持 UIA 可以使用微软官方提供的软件 Inspect，\n可以从[官网](https://learn.microsoft.com/en-us/windows/win32/winauto/inspect-objects)或者[这个仓库](https://github.com/yihleego/Windows-Kits/tree/master/Inspect)下载：\n\n![inspect.png](images/inspect.png)\n\n示例中微信使用了 UiaApp 模式，因为它是基于 UIA 实现的；\n而企业微信使用了 AirApp 模式，它类似网页中仅有存在一个 Canvas，所有元素都是通过代码绘制渲染，所以只能通过图像识别定位。\n\n### Could not find module 'libiconv.dll'\n\n下载 Visual C++ Redistributable Packages for Visual Studio 2013\nhttps://www.microsoft.com/zh-cn/download/confirmation.aspx?id=40784\n\n### RPA Server 问题\n\n请参考：[2#issue](https://github.com/yihleego/robotic-process-automation/issues/2)\n\n## Contact\n\n- [提交问题](https://github.com/yihleego/robotic-process-automation/issues)\n\n## Attention\n\n**本项目仅供学习参考，请勿用于生产环境。**\n\n## License\n\nThis project is under the MIT license. See the [LICENSE](LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyihleego%2Frobotic-process-automation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyihleego%2Frobotic-process-automation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyihleego%2Frobotic-process-automation/lists"}