简体   繁体   中英

In Windows, how can I enumerate and get text from another window's controls?

More particularly - I have a window handle of another running application. This application contains a TListControl.UnicodeClass control somewhere (I know this from Winspector). How can I, using the Windows API and that window handle, go through all the items in that list control and get the text from all of the items?

You can assume the language is C/C++, though I'll actually be using win32all for python. References to the appropriate API calls would be great.

You want EnumWindows and EnumChildWindows for the enumeration. See here for examples and usage info/warnings.

For window text, once you have the appropriate HWND, you want GetWindowText in general, and control-specific API's if the text is stored in a different place (eg: list controls). For the specific control, you will need to know the specific API, and it may not be available though just Windows API calls (for example, controls with owner-draw items can store their text in the app, not accessible to Windows).

Above answers are completely wrong and don't even know what is a PAS. This has been answered hundreds of times for 20 years on Usenet. You must use IPC of course (RPM)

ask on news://comp.os.ms-windows.programmer.win32 for code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM