2

给定父窗口的句柄,如何获取该窗口内按钮的句柄?

win32api.sendMessage( )用来将值传递给窗口。我想用来BM_CLICK点击有问题的按钮。

import win32api
import win32gui
import win32con

#get handle of the window I want

hwnd=win32gui.FindWindow(0,"SOME TITLE")

#btnHnd= (NEED CODE HERE TO GET THE HANDLE OF THE BUTTON INSIDE hwnd)

win32api.SendMessage(btnHnd, win32con.BM_CLICK, 0, 0)
4

1 回答 1

3
btnHnd= win32api.FindWindowEx(hwnd, 0 , "Button", "#Title")

是查找子窗口句柄的方法,前提是按钮是父级的直接子级,而不仅仅是后代

于 2012-07-18T20:39:15.807 回答