Skip to content

Commit

Permalink
2023/11/28更新
Browse files Browse the repository at this point in the history
  • Loading branch information
LTEnjoy committed Nov 28, 2023
1 parent 821d957 commit 588f9fc
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions ui_auto_wechat.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,7 @@ def find_all_contacts(self):
return list(set(contacts))

# 检测微信是否收到新消息
def check_new_msg(self, click_msg: bool = True):
"""
Args:
click_msg: 是否点击新消息确认已读。如果关闭可能导致循环卡顿(双击聊天按钮始终无法跳到下一个新消息)
"""
def check_new_msg(self):
self.open_wechat()
self.get_wechat()

Expand All @@ -193,27 +188,25 @@ def check_new_msg(self, click_msg: bool = True):
item = auto.ListItemControl(Depth=10)
double_click(chat_btn)
# 持续点击聊天按钮,直到获取完全部新消息
first_name = item.Name
last_name = item.Name
first_name = item.ButtonControl().Name
last_name = item.ButtonControl().Name
while True:
print(item.Name)
# 判断该联系人是否需要自动回复
if item.Name in self.auto_reply_contacts:
if item.ButtonControl().Name in self.auto_reply_contacts:
self._auto_reply(item, self.auto_reply_msg)
# print("需要自动回复")

elif click_msg:
else:
click(item)

# 跳转到下一个新消息
double_click(chat_btn)
item = auto.ListItemControl(Depth=10)

# 已经完成遍历,退出循环
if first_name == item.Name or last_name == item.Name:
if first_name == item.ButtonControl().Name or last_name == item.ButtonControl().Name:
break

last_name = item.Name
last_name = item.ButtonControl().Name

# 设置自动回复的联系人
def set_auto_reply(self, contacts):
Expand Down Expand Up @@ -375,6 +368,9 @@ def get_dialogs(self, name: str, n_msg: int) -> List:
text = "你好"
file = "C:/Users/Dell/Pictures/takagi.jpeg"

auto_reply_names = ["周禧彬0313"]
wechat.set_auto_reply(auto_reply_names)

wechat.check_new_msg()

# wechat.send_msg(name, text)
Expand Down

0 comments on commit 588f9fc

Please sign in to comment.