{"id":21707326,"url":"https://github.com/hello-mr-crab/pywechat","last_synced_at":"2025-04-09T19:16:49.259Z","repository":{"id":261714687,"uuid":"885118918","full_name":"Hello-Mr-Crab/pywechat","owner":"Hello-Mr-Crab","description":"pywechat是一个基于pywinauto实现的windows桌面微信自动化操作工具，基本实现了PC微信内置的各项操作","archived":false,"fork":false,"pushed_at":"2025-04-08T12:20:23.000Z","size":10249,"stargazers_count":47,"open_issues_count":5,"forks_count":12,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-09T19:16:42.359Z","etag":null,"topics":["python","pywechat","pywinauto","wechat"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Hello-Mr-Crab.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":"2024-11-08T01:45:55.000Z","updated_at":"2025-04-08T12:20:26.000Z","dependencies_parsed_at":"2024-11-08T02:39:52.427Z","dependency_job_id":"f2f3a3d7-4d08-476c-b7db-f9085b738172","html_url":"https://github.com/Hello-Mr-Crab/pywechat","commit_stats":null,"previous_names":["hello-mr-crab/pywechat"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hello-Mr-Crab%2Fpywechat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hello-Mr-Crab%2Fpywechat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hello-Mr-Crab%2Fpywechat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hello-Mr-Crab%2Fpywechat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Hello-Mr-Crab","download_url":"https://codeload.github.com/Hello-Mr-Crab/pywechat/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248094988,"owners_count":21046770,"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":["python","pywechat","pywinauto","wechat"],"created_at":"2024-11-25T22:17:04.172Z","updated_at":"2025-04-09T19:16:49.250Z","avatar_url":"https://github.com/Hello-Mr-Crab.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pywechat🥇\r\n![image](https://github.com/Hello-Mr-Crab/pywechat/blob/main/pics/introduction.jpg)\r\n## 🍬🍬pywechat是一个基于pywinauto实现的Windows系统下PC微信自动化的Python项目。基本实现了PC微信内置的所有功能,支持单线程多任务轮流进行,完全模拟真人操作微信!!\r\n\r\n### 微信版本:3.9.12.xx\r\n### 操作系统:🪟windows 10 🪟windows 11\r\n### python版本🐍:3.x\r\n### pywechat项目结构：\r\n![image](https://github.com/Hello-Mr-Crab/pywechat/blob/main/pics/pywechat架构图.png)\r\n\u003cbr\u003e\r\n ### 注意，新版本pywechat内所有模块下的类或函数均可直接从pywechat导入，即\r\n   ```\r\n  from pywechat impot xx(class)\r\n  from pywechat import xx(function)\r\n  ```\r\n\u003cbr\u003e\r\n\r\n##  你只需要将微信WeChat.exe文件地址传入pywechat各个函数，或直接添加到windows用户环境变量中即可实现从自动登录到自动回复的一系列微信自动化之旅。🗺️🗺️\r\n### 注:pywechat最新版本已内置自动添加WeChat.exe为windows用户环境变量的方法。\r\n这里建议将微信Wechat.exe文件路径添加到windows系统环境变量中，当微信未启动时pywechat默认使用windows环境变量中的Wechat.exe路径启动微信,此时调用其中的每个方法与函数无需传入wechat_path参数即可自动化操作微信。\r\n\r\n\u003cbr\u003e\r\n\r\n### 获取方法:\r\n#### 最新版本:1.8.8\r\n```\r\npip install pywechat127==1.8.8\r\n```\r\n\u003cbr\u003e\r\n\r\n```\r\npip install --upgrade pywechat127\r\n```\r\n\u003cbr\u003e\r\n\r\n### 添加微信至windows用户环境变量:\r\n#### pywechat已内置自动添加微信至用户环境变量的方法,运行下列代码即可自动添加微信路径至windows用户变量 :\r\n```\r\nfrom pywechat.WechatTools import Tools\r\nTools.set_wechat_as_environ_path()\r\n```\r\n\r\n#### 效果演示:\r\n![Alt text](https://github.com/Hello-Mr-Crab/pywechat/blob/main/pics/演示效果.gif)\r\n\u003cbr\u003e\r\n\r\n### WechatTools🌪️🌪️\r\n#### 模块包括:\r\n#### Tools:关于PC微信的一些工具,包括3个关于PC微信程序的方法和10个打开PC微信内各个界面的open系列方法。\r\n#### API:打开指定微信小程序，指定公众号,打开视频号的功能，若有其他开发者想自动化操作上述程序可调用此API。\r\n#### 函数:该模块内所有函数与方法一致。\r\n\u003cbr\u003e\r\n\r\n### WechatAuto🛏️🛏️\r\n#### 模块包括：\r\n##### Messages: 5种类型的发送消息方法，包括:单人单条,单人多条,多人单条,多人多条,转发消息:多人同一条。 \r\n##### Files: 5种类型的发送文件方法，包括:单人单个,单人多个,多人单个,多人多个,转发文件:多人同一个。发送多个文件时，你只需将所有文件放入文件夹内，将文件夹路径传入即可。\r\n##### FriendSettings: 涵盖了PC微信针对某个好友的全部操作的方法。\r\n##### GroupSettings: 涵盖了PC微信针对某个群聊的全部操作的方法。\r\n##### Contacts: 获取3种类型通讯录好友的备注与昵称包括:微信好友,企业号微信,群聊名称与人数，数据返回格式为json。\r\n##### Call: 给某个好友打视频或语音电话。\r\n##### AutoReply:自动接听微信视频或语音电话,自动回复指定好友消息,自动回复所有好友消息。\r\n#### 函数:该模块内所有函数与方法一致。  \r\n\u003cbr\u003e\r\n\r\n### WinSettings🔹🔹\r\n#### 模块包括：\r\n#### Systemsettings:该模块中提供了7个修改windows系统设置和3个判断文件类型的方法。\r\n#### 函数：该模块内所有函数与方法一致。\r\n\u003cbr\u003e\r\n\r\n### 使用示例:\r\n#### 所有自动化操作只需两行代码即可实现，即：\r\n```\r\nfrom pywechat import xxx\r\nxxx\r\n```\r\n\u003cbr\u003e\r\n\r\n#### (注意，微信WeChat.exe路径已添加至windows系统环境变量,故当微信还未登录时,以下方法或函数无需传入wechat_path这一参数)\r\n#### 给某个好友发送多条信息：\r\n```\r\nfrom pywechat.WechatAuto import Messages\r\nMessages.send_messages_to_friend(friend=\"文件传输助手\",messages=['你好','我正在使用pywechat操控微信给你发消息','收到请回复'])\r\n```\r\n##### 或者\r\n```\r\nimport pywechat.WechatAuto as wechat\r\nwechat.send_messages_to_friend(friend=\"文件传输助手\",messages=['你好','我正在使用pywechat操控微信给你发消息','收到请回复'])\r\n```\r\n\u003cbr\u003e\r\n\r\n#### 自动接听语音视频电话:\r\n```\r\nfrom pywechat.WechatAuto import AutoReply\r\nAutoReply.auto_answer_call(broadcast_content='您好，我目前不在线我的PC微信正在由我的微信机器人控制请稍后再试',message='您好，我目前不在线我的PC微信正在由我的微信机器人控制请稍后再试',duration='1h',times=1)\r\n```\r\n##### 或者\r\n```\r\nimport pywechat.WechatAuto as wechat\r\nwechat.auto_answer_call(broadcast_content='您好，我目前不在线我的PC微信正在由我的微信机器人控制请稍后再试',message='您好，我目前不在线我的PC微信正在由我的微信机器人控制请稍后再试',duration='1h',times=1)\r\n```\r\n### 多任务使用示例\r\n#### 注意,微信不支持多线程，只支持单线程多任务轮流执行，pywechat也支持单线程多任务轮流执行，在运行多个实例时尽量请将所有函数与方法内的close_wechat参数设为False(默认为True)\r\n#### 这样只需要打开一次微信，多个任务便可以共享资源,更加高效，否则，每个实例在运行时都会重启一次微信，较为低效。\r\n\u003cbr\u003e\r\n\r\n```\r\nfrom pywechat.WechatAuto import Messages,Files\r\nMessages.send_messages_to_friend(friend='好友1',messages=['在测试','ok'],close_wechat=False)\r\nFiles.send_files_to_friend(friend='文件传输助手',folder_path=r\"E:\\OneDrive\\Desktop\\测试专用\",with_messages=True,messages_first=True,messages=['在测试文件消息一起发，你应该先看到这条消息，后看到文件'],close_wechat=True)\r\n```\r\n#### 效果演示:\r\n![Alt text](https://github.com/Hello-Mr-Crab/pywechat/blob/main/pics/效果演示.gif)\r\n\r\n\u003cbr\u003e\r\n\r\n##### 自动回复效果:\r\n\r\n![Alt text](https://github.com/Hello-Mr-Crab/pywechat/blob/main/pics/Ai接入实例.png)\r\n\r\n### 检查新消息示例\r\n\u003cbr\u003e\r\n\r\n```\r\nfrom pywechat import check_new_message\r\nprint(check_new_message())\r\n```\r\n\r\n##### 检查新消息效果：\r\n\r\n![Alt text](https://github.com/Hello-Mr-Crab/pywechat/blob/main/pics/check_new_message.gif)\r\n\r\n##### 若你开启了语音自动转消息功能后,新消息中含有语音消息的话,可以将其转换结果一并记录。（1.8.8版本支持此功能）\r\n## 注意:\r\n👎👎请勿将pywechat用于任何非法商业活动,因此造成的一切后果由使用者自行承担！ \r\n\r\n###### 作者CSDN主页:https://blog.csdn.net/weixin_73953650?spm=1011.2415.3001.5343\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhello-mr-crab%2Fpywechat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhello-mr-crab%2Fpywechat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhello-mr-crab%2Fpywechat/lists"}