在窗口内查找控件的句柄 [英] Finding Handle of a control inside a window
本文介绍了在窗口内查找控件的句柄的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
给定父窗口的句柄,如何获取该窗口内按钮的句柄?
Given the handle to a parent window, How can I get the handle of a button inside this window?
我正在使用 win32api.sendMessage( )
将值传递给窗口.我想使用 BM_CLICK
来点击有问题的按钮.
I'm using win32api.sendMessage( )
to pass values to a window. I want to use BM_CLICK
to click on the button in question.
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)
推荐答案
btnHnd= win32api.FindWindowEx(hwnd, 0 , "Button", "#Title")
是找到子窗口句柄的方法,前提是按钮是父级的直接子级,而不仅仅是后代
is the way to find the handle of the child window, provided the button is a direct child of the parent, not just a descendent
这篇关于在窗口内查找控件的句柄的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文