转发该消息 Args: friend (str): 转发给的好友昵称、备注或微信号 Returns: bool: 是否成功转发
(self, friend)
| 902 | return True |
| 903 | |
| 904 | def forward(self, friend): |
| 905 | """转发该消息 |
| 906 | |
| 907 | Args: |
| 908 | friend (str): 转发给的好友昵称、备注或微信号 |
| 909 | |
| 910 | Returns: |
| 911 | bool: 是否成功转发 |
| 912 | """ |
| 913 | wxlog.debug(f'转发消息:{self.sender} --> {friend} | {self.content}') |
| 914 | self._winobj._show() |
| 915 | headcontrol = [i for i in self.control.GetFirstChildControl().GetChildren() if i.ControlTypeName == 'ButtonControl'][0] |
| 916 | RollIntoView(self.chatbox.ListControl(), headcontrol, equal=True) |
| 917 | xbias = int(headcontrol.BoundingRectangle.width()*1.5) |
| 918 | headcontrol.RightClick(x=xbias, simulateMove=False) |
| 919 | menu = self._winobj.UiaAPI.MenuControl(ClassName='CMenuWnd') |
| 920 | forward_option = menu.MenuItemControl(Name="转发...") |
| 921 | if not forward_option.Exists(maxSearchSeconds=0.1): |
| 922 | wxlog.debug('该消息当前状态无法转发') |
| 923 | return False |
| 924 | forward_option.Click(simulateMove=False) |
| 925 | SetClipboardText(friend) |
| 926 | contactwnd = self._winobj.UiaAPI.WindowControl(ClassName='SelectContactWnd') |
| 927 | contactwnd.SendKeys('{Ctrl}a', waitTime=0) |
| 928 | contactwnd.SendKeys('{Ctrl}v') |
| 929 | checkbox = contactwnd.ListControl().CheckBoxControl() |
| 930 | if checkbox.Exists(1): |
| 931 | checkbox.Click(simulateMove=False) |
| 932 | contactwnd.ButtonControl(Name='发送').Click(simulateMove=False) |
| 933 | return True |
| 934 | else: |
| 935 | contactwnd.SendKeys('{Esc}') |
| 936 | raise FriendNotFoundError(f'未找到好友:{friend}') |
| 937 | |
| 938 | def parse(self): |
| 939 | """解析合并消息内容,当且仅当消息内容为合并转发的消息时有效""" |
nothing calls this directly
no test coverage detected