转发该消息 Args: friend (str): 转发给的好友昵称、备注或微信号 Returns: bool: 是否成功转发
(self, friend)
| 791 | return True |
| 792 | |
| 793 | def forward(self, friend): |
| 794 | """转发该消息 |
| 795 | |
| 796 | Args: |
| 797 | friend (str): 转发给的好友昵称、备注或微信号 |
| 798 | |
| 799 | Returns: |
| 800 | bool: 是否成功转发 |
| 801 | """ |
| 802 | wxlog.debug(f'转发消息:{self.sender} --> {friend} | {self.content}') |
| 803 | self._winobj._show() |
| 804 | headcontrol = [i for i in self.control.GetFirstChildControl().GetChildren() if i.ControlTypeName == 'ButtonControl'][0] |
| 805 | RollIntoView(self.chatbox.ListControl(), headcontrol, equal=True) |
| 806 | xbias = int(headcontrol.BoundingRectangle.width()*1.5) |
| 807 | headcontrol.RightClick(x=-xbias, simulateMove=False) |
| 808 | menu = self._winobj.UiaAPI.MenuControl(ClassName='CMenuWnd') |
| 809 | forward_option = menu.MenuItemControl(Name="转发...") |
| 810 | if not forward_option.Exists(maxSearchSeconds=0.1): |
| 811 | wxlog.debug('该消息当前状态无法转发') |
| 812 | return False |
| 813 | forward_option.Click(simulateMove=False) |
| 814 | SetClipboardText(friend) |
| 815 | contactwnd = self._winobj.UiaAPI.WindowControl(ClassName='SelectContactWnd') |
| 816 | contactwnd.SendKeys('{Ctrl}a', waitTime=0) |
| 817 | contactwnd.SendKeys('{Ctrl}v') |
| 818 | checkbox = contactwnd.ListControl().CheckBoxControl() |
| 819 | if checkbox.Exists(1): |
| 820 | checkbox.Click(simulateMove=False) |
| 821 | contactwnd.ButtonControl(Name='发送').Click(simulateMove=False) |
| 822 | return True |
| 823 | else: |
| 824 | contactwnd.SendKeys('{Esc}') |
| 825 | raise FriendNotFoundError(f'未找到好友:{friend}') |
| 826 | |
| 827 | def parse(self): |
| 828 | """解析合并消息内容,当且仅当消息内容为合并转发的消息时有效""" |
nothing calls this directly
no test coverage detected