8523526
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
The handler is indeed called for each child:>>> def all_ok(hwnd, param):... print hwnd... return True...>>> win32gui.EnumChildWindows(parent_handle, all_ok, None)17630538129119408260536413143214356400114718889048526
handle =
win
32
gui
.Find
Win
dow(classname, title)
handle =
win
32
gui
.GetForeground
Win
dow()--------------<获取所有
窗口
最上面的句
柄
>
二.获取字句
柄
的方法:
hwnd =
win
32
gui
.Find
Win
dowEx(parent_handle, handle_...
unsigned int tid = 0;
HANDLE handle = (HANDLE)_beginthreadex(NULL, 0, Find
Win
dowsThread, this, 0, &tid);
CloseHandle(handle);
Enum
Win
dows函数(
win
user.h)
通过将句
柄
传递给每个
窗口
,
BOOL CALLBACK EnumChildProc(HWND hwndChild, LPARAM lParam)
HWND hwnd = GetDlgItem(hwndChild,lParam);
if (NULL != hwnd)
CWnd* pbtn = CWnd::FromHandle(hwnd);
CODPButton *pCbtn = (CODPButton *)
fff.huoqujubing() hwnd =
win
32
gui
.Find
Win
dow(None, "【魔域】") print(hwnd) controls = []
win
32
gui
.
EnumChildWindows
(hwnd, lambda hwnd, param: param.append(hwnd), controls) for control in controls: title =
win
32
gui
.Get
Win
dowText(control) 将获取的 内容保存为TXT