使用pywinauto获取Zoom会议全部参会者(含屏幕外不可见列表项)
解决方案
提供两种可直接使用的实现方式,你可以根据实际运行效果选择:
方案1:无需可见,一次性获取全部参会者
Zoom的参会者列表是标准UIA控件,使用uia后端初始化pywinauto时,可直接通过descendants筛选所有ListItem类型的子控件,无需滚动即可拿到全部项:
from pywinauto import Application # 注意初始化Zoom应用时要指定backend='uia',示例: # zoom_meeting = Application(backend='uia').connect(title_re=".*Zoom Meeting.*") # 定位参会者列表控件,和你原有逻辑一致 participants_list_box = zoom_meeting.Participants.child_window(title="participant list, use arrow key to navigate, and press tab for more options", control_type="List").wrapper_object() attendees = [] # 直接筛选所有列表项,无需考虑是否可见 all_items = participants_list_box.descendants(control_type="ListItem") for item in all_items: window_text = item.window_text() if not window_text: continue # 提取姓名逻辑和你原有逻辑保持一致 attendee_name = window_text.split(",")[0] # 去重避免重复添加 if attendee_name not in attendees: attendees.append(attendee_name)
注意:如果运行后还是只能拿到可见项,说明Zoom的列表是虚拟渲染的,可改用下方滚动加载方案。
方案2:滚动列表逐行采集全量参会者
通过模拟键盘向下滚动的方式遍历所有项,滚动过程中持续采集,直到没有新的参会者出现为止:
import time participants_list_box = zoom_meeting.Participants.child_window(title="participant list, use arrow key to navigate, and press tab for more options", control_type="List").wrapper_object() participants_list_box.set_focus() attendees = [] last_count = 0 # 连续2次采集到的人数一致就认为已经滑到底部 same_count_times = 0 while same_count_times < 2: # 采集当前可见的参会者 for child in participants_list_box.children(control_type="ListItem"): window_text = child.window_text() if not window_text: continue attendee_name = window_text.split(",")[0] if attendee_name not in attendees: attendees.append(attendee_name) # 统计当前人数 current_count = len(attendees) if current_count == last_count: same_count_times += 1 else: same_count_times = 0 last_count = current_count # 模拟向下翻页,滚动列表 participants_list_box.type_keys("{PGDN}") time.sleep(0.3)
可以根据你设备的响应速度调整
time.sleep的等待时长,避免滚动过快漏采。
内容的提问来源于stack exchange,提问作者The Royal Guardian
相关产品推荐
相关产品推荐

