简体   繁体   中英

Get text from a windowsless control

I was wondering how can I read text of a control that doesn't have an HWND. For instance, the print dialog in office 2007 doesn't have HWND on all of its controls (only a few).

Is there anyway to get the text from these controls? I believe they're simply drawn on the window and react using HITTEST, but I'm not sure, so I'm asking you guys:-).

Thanks for your help!

Generally, there is no guaranteed way to do that. However, chances are you can get the text (and other info about the controls) using the IAccessible interface . Most Microsoft products implement this interface on most of the UI elements: this is how screen readers for disabled people work

For a generic windowless control, all you can assume is that the text exists only as pixels on the screen, so the only way to read it is with OCR.

If you can learn more information about the specific controls you want to inspect, then you might learn that the windowless control has a parent window that handles messages on its behalf, or that the control has a COM object you can manipulate, or that the control honors the Windows accessibility API. If you don't know anything else about the control, then all you have are the pixels.

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