Skip to content

微信支持多开以及新增方法:填充文本到输入框:InputMsg,入参SendMsg一致。 #288

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: WeChat3.9.11
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions wxauto/wxauto.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ class WeChat(WeChatBase):
SessionItemList: list = []

def __init__(
self,
self,
uia_api = uia.WindowControl(ClassName='WeChatMainWndForPC', searchDepth=1),
language: Literal['cn', 'cn_t', 'en'] = 'cn',
debug: bool = False
) -> None:
Expand All @@ -34,7 +35,7 @@ def __init__(
Args:
language (str, optional): 微信客户端语言版本, 可选: cn简体中文 cn_t繁体中文 en英文, 默认cn, 即简体中文
"""
self.UiaAPI: uia.WindowControl = uia.WindowControl(ClassName='WeChatMainWndForPC', searchDepth=1)
self.UiaAPI: uia.WindowControl = uia_api
set_debug(debug)
self.language = language
# self._checkversion()
Expand Down Expand Up @@ -372,8 +373,8 @@ def AtAll(self, msg=None, who=None):
else:
editbox.SendKeys('{Enter}')

def SendMsg(self, msg, who=None, clear=True, at=None):
"""发送文本消息
def InputMsg(self, msg, who=None, clear=True, at=None):
"""输入文本消息,不发送

Args:
msg (str): 要发送的文本消息
Expand Down Expand Up @@ -426,6 +427,18 @@ def SendMsg(self, msg, who=None, clear=True, at=None):
editbox.SendKeys('{Ctrl}v')
if editbox.GetValuePattern().Value:
break

return editbox

def SendMsg(self, msg, who=None, clear=True, at=None):
"""发送文本消息
Args:
msg (str): 要发送的文本消息
who (str): 要发送给谁,如果为None,则发送到当前聊天页面。 *最好完整匹配,优先使用备注
clear (bool, optional): 是否清除原本的内容,
at (str|list, optional): 要@的人,可以是一个人或多个人,格式为str或list,例如:"张三"或["张三", "李四"]
"""
editbox = self.InputMsg(msg, who, clear, at)
editbox.SendKeys('{Enter}')

def SendFiles(self, filepath, who=None):
Expand Down