我正在做一个自动程序(C#,而不是 C++),我需要在表单中获取 RichTextBox。我已经使用Spy++
来获取标题和类名,但FindWindowEx
始终找不到RichTextBox
,并GetLastError
获取单词0
。然后这是一个简单的例子。
IntPtr parent = FindWindow(null, "Form1");
if (parent!=IntPtr.Zero) {
//find test1 textbox
IntPtr child = FindWindowEx(parent, 0,null, "test1");
if (child!=IntPtr.Zero) {
SendMessage(child, 0x000c, 0, lParam: "test");
} else {
Console.WriteLine("textbox can't be found");
}
//find test2 richtextbox
IntPtr childRich = FindWindowEx(parent, 0, null, "test2");
if (childRich != IntPtr.Zero) {
SendMessage(child, 0x000c, 0, lParam: "test");
} else {
Console.WriteLine("richtextbox can't be found");
}
} else {
Console.WriteLine("Form1 can't be found");
}
但结果是richtextbox can't find
。帮我。