wxauto icon indicating copy to clipboard operation
wxauto copied to clipboard

设置循环发送实现群发,但是有部分群被踢出去了,然后就会报错Find Control Timeout(10s): {SubName: '。。', ControlType: EditControl

Open HuFakai opened this issue 2 years ago • 2 comments

设置循环发送实现群发,但是有部分群被踢出去了,然后就会报错Find Control Timeout(10s): {SubName: '。。', ControlType: EditControl,如果这个群被踢了,怎么让他不报错,结束当前这个,然后继续执行下一个循环发送消息?

HuFakai avatar Sep 06 '23 16:09 HuFakai

被踢的话应该会收到系统发的消息,可以用这个消息作为判断

liaaaa2 avatar Sep 15 '23 06:09 liaaaa2

修改了SendMsg通过判断 EditControl,来识别是否被删除或者未添加好友,从而实现群发for循环不会报错中断

def SendMsg(self, msg, who, clear=True): '''向当前窗口发送消息 msg : 要发送的消息 clear : 是否清除当前已编辑内容 ''' if self.UiaAPI.EditControl(SubName=who).Exists(maxSearchSeconds=0.001) ==True: self.UiaAPI.SwitchToThisWindow() self.EditMsg = self.UiaAPI.EditControl(SubName=who)

        if clear:
            self.EditMsg.SendKeys('{Ctrl}a', waitTime=0)
        self.EditMsg.SendKeys(msg, waitTime=0)
        self.EditMsg.SendKeys('{Enter}', waitTime=0)
        print('存在')
    else:
        self.UiaAPI.SendKeys('{Tab}', waitTime=1)
        self.SearchBox.SendKeys('{Enter}')
        print('不存在')

HuFakai avatar Sep 20 '23 11:09 HuFakai