5

所以基本上我有这个以列表形式输出数据的软件。感谢这里的评论,我们了解到它很可能是用 .NET 编写的。

我想扫描列表,这样我就可以对数据做一些算法。

使用 Spy++,我发现保存此列表的标题为“Panel2”,我可以使用 EnumChildWindows 获取此列表的句柄(其类为“WindowsForms10.Window.8.app”)。

但是我不知道如何进入列表本身,所以我可以阅读它的项目。我已经在“Panel2”句柄上尝试了 EnumChildWindows 并输出了所有这些窗口的标题,但它们都是空的。

panel2 可以是实际列表吗?如果是这样,我可以将其转换为 (CListCtrl*) 吗?

Axilles 在评论中提到它可能是用 .NET 编写的,是否可以使用http://reflector.red-gate.com/download.aspx?TreatAsUpdate=1之类的东西来获取列表的 controlID / 句柄?

   CWnd* mainWindow;
    CWnd* panel;
    CListCtrl* list;



BOOL CALLBACK findWindow( HWND hwnd,LPARAM lParam)
{
    char text[8];
    GetWindowText(hwnd,text,8);

    if(strcmp(text,"Fetcher") == 0)
    {
        mainWindow= CWnd::FromHandle(hwnd);

        return false;
    }

    return true;
}

BOOL CALLBACK findPanel(HWND hwnd,LPARAM lParam)
{

    char text[7];
    GetWindowText(hwnd,text,7);

    if(strcmp(text,"Panel2") == 0)
    {
        panel = CWnd::FromHandle(hwnd);

        return false;
    }

    return true;
}


void CAnalyzeDlg::OnBnClickedButton1()
{
    mainWindow = 0;

    while(mainWindow == 0)
    {
    ::EnumWindows(findWindow,0);
    }

    mainWindow ->ActivateTopParent();

    while(panel == 0) ::EnumChildWindows(mainWindow ->m_hWnd,findPanel,0);

    CWnd* pointTest = NULL;

    CString text = "";

    int xx = 337;
    int yy = 95;

    while(yy < 1024 && (pointTest == NULL || strcmp(text,"") == 0 || strcmp(text,"Panel2") == 0))
    {
        pointTest = mainWindow->ChildWindowFromPoint(CPoint(xx,yy));
        yy++;
        if(pointTest != 0)
            pointTest->GetWindowTextA(text);
    }



    if(strcmp(text,"") != 0)
        MessageBox(0,text,0); // This never shows

}
4

1 回答 1

6

Spy++ 是一个出色的工具,但它不支持 .Net。我建议在应用程序上尝试 UISpy.exe 以查看它能够找到比 Spy++ 更多的元素。UISpy.exe 可以在http://msdn.microsoft.com/en-us/library/ms727247.aspx找到,还有 ManagedSpy.exe http://msdn.microsoft.com/en-us/magazine/ cc163617.aspx

您可以通过将调试器附加到应用程序来确定应用程序是否是 .Net 应用程序(Visual Studio 或 WinDBG;如果您还没有 Visual Studio,我建议您使用免费版本的 VC++,因为我没有确保 C# 版本具有本机调试支持)。另一种选择是使用 Windows 平台 SDK 中的depends.exe,甚至只是http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx中的 ProcessExplorer.exe来查看哪些 DLL 加载到进程中(即.Net 应用程序将加载核心 .Net DLL)。

如果该列表实际上是一个 Windows Presentation Forms (WPF) 列表,您可能必须利用 .Net UIAutomation 类来访问列表的内容。UIAutomation 记录在这里:http: //msdn.microsoft.com/en-us/library/ms747327.aspx

编辑:根据 MSDN 文档,UISpy.exe 现在已过时:

注意 Accessible Explorer 和 UI Spy 工具已过时且不再可用。开发人员应改为使用 Inspect 或 AccScope。

于 2012-11-11T18:48:21.073 回答