Skip to content
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

微信发送消息是否可以增加换行 #15

Closed
six-days opened this issue Nov 11, 2022 · 2 comments
Closed

微信发送消息是否可以增加换行 #15

six-days opened this issue Nov 11, 2022 · 2 comments

Comments

@six-days
Copy link

在发送消息是,有时内容需要换行。建议可以对\n这样的换行符进行特殊处理,转化为Ctrl+Enter,实现内容换行。

@asia90li
Copy link

def SendMsg(self, msg, clear=True):
    '''向当前窗口发送消息
    msg : 要发送的消息
    clear : 是否清除当前已编辑内容
    '''
    # 对发送信息分割
    msg_list = msg.strip().split('\n')
    # print(msg_list)
    self.UiaAPI.SwitchToThisWindow()
    if clear:
        self.EditMsg.SendKeys('{Ctrl}a', waitTime=0)
    # 判断发送信息长度,大于1条换行编写发送信息,其他单条发送信息
    if len(msg_list) > 1:
        for tmp in msg_list:
            self.EditMsg.SendKeys(tmp, waitTime=0)
            self.EditMsg.SendKeys('{Ctrl}{Enter}', waitTime=0)
    else:
        self.EditMsg.SendKeys(msg, waitTime=0)
    # 回车发送信息
    self.EditMsg.SendKeys('{Enter}', waitTime=0)

@CoderWanFeng
Copy link
Owner

换行功能,实现见链接里的:2、常见问题:https://www.python-office.com/office/robot.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants