I'm trying to ge the handle for "Yes" button in a dialog, so I can send the message to click it.
I get the dialog and then I try to find the button, but I always get 0 back.
import win32gui
hwnd = win32gui.FindWindow("#32770", "Programs and Features")
# got back the correct handle to the dialog
win32gui.SetForegroundWindow(hwnd)
btnhdl = win32gui.FindWindowEx(hwnd, 0, "Button", "&Yes")
# returns 0
The button is there and the class and title seem to be ok. I verified it by this:
def printClasses(childHwnd, lparam):
if win32gui.GetWindowText(childHwnd) == "&Yes":
print win32gui.GetClassName(childHwnd), win32gui.GetWindowText(childHwnd)
return 1
win32gui.EnumChildWindows(hwnd, printClasses, None)
# output: Button &Yes
Looks like everything should be fine, but why it doesn't return the handle with FindWindowEx
?
Thanks