def dumpWindow_pos(hwnd):
'''Dump all controls from a window into a nested list
Useful during development, allowing to you discover the structure of the
contents of a window, showing the text and class of all contained controls.
Arguments: The window handle of the top level window to dump.
Returns A nested list of controls. Each entry consists of the
control's hwnd, its text, its class, and its sub-controls,
if any.
Usage example: replaceDialog = findTopWindow(wantedText='Replace')
pprint.pprint(dumpWindow(replaceDialog))
'''
windows = []
try:
win32gui.EnumChildWindows(hwnd, _windowEnumerationHandler, windows)
except win32gui.error:
# No child windows
return
windows = [list(window) for window in windows]
for window in windows:
childHwnd, windowText, windowClass = window
window_content = dumpWindow(childHwnd)
if window_content:
window.append(window_content)
print '###################'
print childHwnd,'pos:',win32gui.GetWindowRect(childHwnd),'window_content:',window_content
tuple_t = win32gui.GetWindowRect(childHwnd)
if tuple_t[0]==179 and tuple_t[2]==561:
print window_content[0][0],'pos:',win32gui.GetWindowRect(window_content[0][0])
if window_content[0][0]:
bufLen=1024
buf =win32gui.PyMakeBuffer(bufLen)
n = win32gui.SendMessage(window_content[0][0],win32con.WM_GETTEXT,bufLen,buf)
str = buf[:n]
print str
print getEditText(window_content[0][0])
time.sleep(1)
#win32gui.SendMessage(window_content[0][0],win32con.WM_SETTEXT,None,'Realtek 10/100/1000 Ethernet NIC')
print '###################'
return windows
win_GUI.py 文件源码
python
阅读 19
收藏 0
点赞 0
评论 0
评论列表
文章目录