We don’t allow questions seeking recommendations for software libraries, tutorials, tools, books, or other off-site resources. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(1)
您可能需要查看WM_GETTEXT消息。 这可以用于从其他窗口读取文本 - 这是一个过时的Windows API 的一部分,如果您使用 C#,则需要对其进行 p/invoke。
请查看此页面,了解在 C# 中执行此操作的示例。
基本上,您首先使用 FindControlEx() 来获取所需窗口的句柄(通过标题)。
其次,使用 EnumChildWindows() 递归枚举该窗口上的控件,以查找该窗口的所有子控件以及所有这些子控件的子控件,直到获得目标窗体的完整映射。
以下是 Google 问答中 Theta-ga 的精彩解释的节选部分:
要获取任何文本框或列表框控件的内容,我们所需要的只是它的窗口句柄。 如果您已经获取了窗口句柄,请转到说明的第 2 部分。
第 1 部分:获取控制句柄
第 2 部分:读取控件的内容
You may want to look into the WM_GETTEXT message. This can be used to read text from other windows -- it's an archaic part of the Windows API, and if you're in C#, you'll need to p/invoke for it.
Check out this page for an example of doing this in C#.
Basically, you first FindControlEx() to get the handle of the window that you want (by caption).
Second, you recursively enumerate the controls on that window with EnumChildWindows() to find all of the window's child controls, and all of those children's children until you have a complete map of the target form.
Here is a selected portion of Theta-ga's excellent explanation from Google Answers:
To get the contents of any textbox or listbox control, all we need is it's window handle. If you have already obtained the window handle then move to part 2 of the explaination.
PART 1: Obtaining the control handle
PART 2: Reading the contents of a control