遍历句柄所有子窗口 win32gui.EnumChildWindows

The handler is indeed called for each child:

>>> def all_ok(hwnd, param):
...     print hwnd
...     return True
...

>>> win32gui.EnumChildWindows(parent_handle, all_ok, None)
17630538
12911940
8260536
4131432
14356400
11471888
9048526
18942076
8523526
#etc...
It's just that EnumChildWindows itself doesn't return anything. If you want to have all of the child window handles in a list, do that in the handler:

>>> parent_handle = 33230502
>>> child_handles = []
>>> def all_ok(hwnd, param):
...     child_handles.append(hwnd)
...
>>> win32gui.EnumChildWindows(parent_handle, all_ok, None)
>>> child_handles
[17630538, 12911940, 8260536, 4131432, 14356400, 11471888, 9048526, 18942076, 8523526, 6951400, 5968556, 19203900, 4459544, 15208240, 9700614, 5769012, 11277176, 7409598, 10225510, 8392342, 19270296, 32377256, 7276984, 20449052, 8262502, 11734380, 14749460, 5310608, 3935978, 125374254, 8457268, 2621704, 24840652, 5706936, 35261636, 10357170, 5641372, 8260848, 6559366]
>>>

参考
https://stackoverflow.com/questions/12253858/enumchildwindows-not-working-in-pywin32

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值