C# 如何阅读子窗口
我正在使用此代码读取应用程序的子窗口C# 如何阅读子窗口,c#,winforms,winapi,C#,Winforms,Winapi,我正在使用此代码读取应用程序的子窗口 //Parent Intptr = MainWindow(); ///Caption of main window = "Terminal" public void GetWindows(IntPtr ParentWindowHandle) { string str = "SysListView32"; string str2 = ""; ParentWindowHandle = fun
//Parent Intptr = MainWindow(); ///Caption of main window = "Terminal"
public void GetWindows(IntPtr ParentWindowHandle)
{
string str = "SysListView32";
string str2 = "";
ParentWindowHandle = functions.FindWindowEx(ParentWindowHandle, (IntPtr)(0), ref str, ref str2);
IntPtr[] ptrArray2 = new IntPtr[11];
int i = 0;
IntPtr window = functions.GetWindow(ParentWindowHandle, 5);
while (!window.Equals(IntPtr.Zero))
{
str = "SysListView32";
str2 = "";
ptrArray2[i] = functions.FindWindowEx(window, ptrArray2[i], ref str, ref str2);
int len = functions.SendMessage(window, 14, IntPtr.Zero, IntPtr.Zero);
if (len > 0)
{
len++;
StringBuilder lParam = new StringBuilder(len);
functions.SendMessage(window, 13, (IntPtr)len, lParam);
cmb_profile.Items.Add(lParam.ToString());
}
window = functions.GetWindow(window, 2);
i++;
}
}
我去拿窗户
A) 英镑美元,H4B) 英镑美元,上半年
C) 英镑/美元,每日 但我没有得到市场观察:16:24:53 后来我把标题市场观察:16:24:53作为家长IntPtr,但我没有得到任何子窗口 我想读取符号、Bid、Ask列和列表内容,因为它每秒钟更新一次,我想将速率存储在数据库文件中 如果有人能帮助我,我将不胜感激
提前感谢。首先,为了理解这一点,您必须声明一些消息常量,以避免在代码中使用魔法常量 您计划的下一步,阅读列表视图内容,使用当前策略是很棘手的。您需要使用LVM_GETITEMTEXT来读取内容。但这需要传递一个指向LVITEM结构的指针。关键是必须在目标进程的地址空间中分配结构。这需要使用以下API:OpenProcess、VirtualAllocEx、WriteProcessMemory、ReadProcessMemory 这项技术是可能的,并且已知是有效的。在websearch中可以找到无数这样的例子。然而,细节是相当棘手的,特别是如果你不是一个专业的Win32程序员。再加上C#中低级编程的笨拙,你就会犯错误
还有另一种更好的方法:UIAutomation。你能给我提供一些示例代码来实现这一点吗?我已经用图片更新了我的问题,你可能知道我的问题是什么,我知道你的问题是什么。您所需要做的就是通过Web搜索来查找示例代码。无论如何,你目前的方法是错误的。切换到UIAutomation。