Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
I am using python 3.11 to achieve some windows ui automation using win32gui. The objective is to progrmatically find a TARGET child object inside a WINDOW NAME parent window, both name known and will not change. So far I cannot figure out how to access anything inside the parent window's tree and this is the only thing (that barely) worked:
hwnd = win32gui.FindWindow(None, 'WINDOW NAME') # parent window
child_hwnd = win32gui.FindWindowEx(hwnd, 0, None, 'TARGET') # target object
window_text = win32gui.GetWindowText(child_hwnd) # extract window text
hwnd
returns the handle of the parent window as int, child_hwnd
returns 0, window text
returns empty string. Although it does not provide any useful information it means that I am able to locate and get the handle of the parent window. The problem is probably that my TARGET is not a window but a list object.
I have checked the TARGET object I want to get using the inspector app from WindowsKit: it is a list object inside a pane object inside a pane object ... inside a window:
screenshot of inspector of TARGET and its ancestors
screenshot of inspector of TARGET in WINDOW NAME's tree
I have also tried EnumChildWindows but it says first param must be a callable object even I input the hwnd
.
My objectives are to: 1.let Python send a query to the WINDOW NAME parent window,
2.get the window and search all its children (any filtering method will work) to find the TARGET,
3.get the TARGET list object (as bytes, strings, anything writeable).
I also tried searching for win32gui automation, but I do not know what keywords to search for so it keeps giving answers missing my point. Any ideas how to achieve the objective or suggestions what I should search for?
–
–
–
–
–
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.