Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Finding Handle of a control inside a window

Tags:

python

winapi

Given the handle to a parent window, How can I get the handle of a button inside this window?

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)
like image 747
asudhak Avatar asked Oct 14 '25 04:10

asudhak


1 Answers

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

like image 122
asudhak Avatar answered Oct 16 '25 18:10

asudhak