time.sleep(1)
friends = []
self.is_get_friends_running = True
friends_list = self.contacts_window.ListControl(ClassName="mmui::ContactsManagerDetailView").GetChildren()
runtimeId = 0
self.contacts_window.ListControl(ClassName="mmui::ContactsManagerDetailView").SetFocus()
auto.SendKeys('{HOME}')
# print(f"runtimeId: {runtimeId} {friends_list[0].Name}")
while self.is_get_friends_running:
index = next((i for i, itme in enumerate(friends_list) if itme.GetRuntimeId() == runtimeId), 0)
# print(f"index: {index}")
for i in range(index, len(friends_list)):
if not self.is_get_friends_running:
return friends
if friends_list[i].BoundingRectangle.top > 0 and friends_list[i].GetRuntimeId() != runtimeId:
name, note, label = friends_list[i].Name.rsplit(" ", maxsplit=2)
friends.append((name, note, label.rsplit(",")))
# print(f"name: {name} note: {note} label: {label}")
runtimeId = friends_list[i].GetRuntimeId()
# self.contacts_window.ListControl(ClassName="mmui::ContactsManagerDetailView").WheelDown(wheelTimes=2)
friends_list[-3].WheelDown(wheelTimes=3)
# time.sleep(0.1)
friends_list = self.contacts_window.ListControl(ClassName="mmui::ContactsManagerDetailView").GetChildren()
if friends_list[-1].BoundingRectangle.top > 0 and runtimeId == friends_list[-1].GetRuntimeId():
print(f"最后一个元素已经显示完全,结束滚动 {friends[-1]}")
break
for friend in friends:
print(friend)
print(f"total: {len(friends)}")
return friends
def get_lable_friends(self, tag_name):
if hasattr(self, 'contacts_window'):
self.contacts_window.SetActive()
print(f"tag_name: {tag_name} {self.wx_friends_tags[tag_name]}")
self.wx_friends_tags[tag_name].Click()