开发者

Get text from a windowsless control

开发者 https://www.devze.com 2023-03-18 13:57 出处:网络
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).

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 c开发者_如何转开发ontrols? 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号