问题描述
问题场景为一个Listbox类型的筛选项,在通过pywin32来发送消息设置某项为选中时,仅标蓝选中未进行dafaultAction的点击动作即执行筛选
win32gui.SendMessage(68992, win32con.LB_SELECTSTRING, 0, '28641')
表现为

,而通过Accessibility Insights for Windows软件可以看到列表项的默认动作为双击

问题解决
对比pywinauto对应listbox的select处理可以发现,代码如下:
def select(self, item, select=True):
"""Select the ListBox item
item can be either a 0 based index of the item to select
or it can be the string that you want to select
"""
if self.is_single_selection() and isinstance(item, (list, tuple)

在使用pywin32处理Listbox时,仅设置选中状态未触发selectChange事件。问题在于缺少通知父窗口的动作。解决方案涉及LB_SELECTSTRING消息后手动发送LBN_SELCHANGE通知。
624

被折叠的 条评论
为什么被折叠?



