From 32a11ff5d2b76ffd5ce18ae02a5930f91ba7882c Mon Sep 17 00:00:00 2001 From: DengerYang <408033187@qq.com> Date: Thu, 12 Sep 2024 18:08:59 +0800 Subject: [PATCH] =?UTF-8?q?fix:#269=20=E6=B7=BB=E5=8A=A0=E8=AF=AD=E9=9F=B3?= =?UTF-8?q?=E8=81=8A=E5=A4=A9=E5=92=8C=E8=A7=86=E9=A2=91=E8=81=8A=E5=A4=A9?= =?UTF-8?q?=E7=9A=84=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wxauto/wxauto.py | 56 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/wxauto/wxauto.py b/wxauto/wxauto.py index e7788b9..41f4f1c 100644 --- a/wxauto/wxauto.py +++ b/wxauto/wxauto.py @@ -487,7 +487,61 @@ def SendFiles(self, filepath, who=None): else: Warnings.lightred('所有文件都无法成功发送', stacklevel=2) return False - + + def VideoCall(self, who=None): + """打开视频聊天 + Args: + who (str): 要发送给谁,如果为None,则发送到当前聊天页面。 *最好完整匹配,优先使用备注 + Returns: + False失败;True 成功 + """ + return self.__openCall(who=who, type=1) + + def VoiceCall(self, who=None): + """打开语音聊天 + Args: + who (str): 要发送给谁,如果为None,则发送到当前聊天页面。 *最好完整匹配,优先使用备注 + Returns: + False失败;True 成功 + """ + return self.__openCall(who=who, type=2) + + def __openCall(self, who=None, type=1): + """打开(语音|视频)聊天 + Args: + who (str): 要发送给谁,如果为None,则发送到当前聊天页面。 *最好完整匹配,优先使用备注 + type (int): 视频聊天=1;语音聊天=2 + Returns: + False失败;True 成功 + """ + if who: + try: + editbox = self.ChatBox.EditControl(searchDepth=10) + if who in self.CurrentChat() and who in editbox.Name: + pass + else: + self.SwitchToChat() + self.ChatWith(who) + except: + self.SwitchToChat() + self.ChatWith(who) + else: + Warnings.lightred('用户不能为空', stacklevel=2) + return False + if type == 1: + ele = self.ChatBox.PaneControl(searchDepth=8, foundIndex=1).ButtonControl(Name='视频聊天') + else: + ele = self.ChatBox.PaneControl(searchDepth=8, foundIndex=2).ButtonControl(Name='语音聊天') + try: + uia.SetGlobalSearchTimeout(1) + rect = ele.BoundingRectangle + Click(rect) + return True + except: + return False + finally: + uia.SetGlobalSearchTimeout(10) + def GetAllMessage(self, savepic=False, savefile=False, savevoice=False): '''获取当前窗口中加载的所有聊天记录