我想获得一个应用程序的控制/手柄的内容..C#如何使用WM_GETTEXT/GetWindowText函数API
这里的实验代码..
Process[] processes = Process.GetProcessesByName("Notepad");
foreach (Process p in processes)
{
StringBuilder sb = new StringBuilder();
IntPtr pFoundWindow = p.MainWindowHandle;
List <IntPtr> s = GetChildWindows(pFoundWindow);
// function that returns a
//list of handle from child component on a given application.
foreach (IntPtr test in s)
{
// Now I want something here that will return/show
the text on the notepad..
}
GetWindowText(pFoundWindow, sb,256);
MessageBox.Show(sb.ToString()); // this shows the title.. no problem with that
}
什么想法? 我提前阅读像GetWindowText函数或WM_GETTEXT一些API方法,但我不知道如何使用它或把它在我的代码.. 我需要一个教程或示例代码...
感谢:)
哇,它的工作原理上的记事本。 。但它不适用于其他应用程序,但我想问题是,我需要控制子组件..也许我需要研究更多;) – user848682
是的,如果你以后的控件是一个子控件在一个给定的窗口,那么你需要迭代地获取控件,并在标题匹配所需的时候停止。 –
uhmm,samra如果你有空闲时间,你能给我一个方法来接受一个句柄并返回一个子控件列表吗?提前致谢。我从网上获得的方法有问题.. – user848682