本帖最后由 lgjgsslgjgss 于 2012-07-10 08:24:08 编辑

解决方案 »

  1.   

    XP系统层次:
    Shell_TrayWnd-->ReBarWindow32-->MSTaskSwWClass-->ToolbarWindow32
      

  2.   

    我用下面也是不行。xp和win7两种系统,我都有调试。
    [DllImport("user32.dll")]
            private static extern int FindWindow(string className, string windowText);
            [DllImport("user32.dll")]
            private static extern int FindWindowEx(int hWnd1, int hWnd2, string lpsz1, string lpsz2); 
            private void Button_Click(object sender, RoutedEventArgs e)
            {
                int handle0 = FindWindow("Shell_TrayWnd", null);
                int handle1 = FindWindowEx(handle0, 0, "ReBarWindow32", null);
                int handle2 = FindWindowEx(handle1, 0, "MSTaskSwWClass", null);
                int handle3 = FindWindowEx(handle2, 0, "ToolbarWindow32", null);
                this.Title = (  handle0 + "  " + handle1 + "  " + handle2 + "  " + handle3   );
            }
      

  3.   

    int handle0 = FindWindow("Shell_TrayWnd", null);
    int handle1 = FindWindowEx(handle0, 0, "ReBarWindow32", null);
    int handle2 = FindWindowEx(handle1, 0, "ToolbarWindow32", null);
    this.Title = (  handle0 + "  " + handle1 + "  " + handle2  );
      

  4.   


    你的代码里,最终handle2是什么?
      

  5.   


    什么意思?你的代码里,handle2是什么窗体(就是说,是哪个可视区域)的句柄?
      

  6.   

    是吗?我在xp下,handle3是零啊。
      

  7.   


    是的,我搞错了。你是正确的,2楼的代码,在xp下是没有问题的。
    那么,在win7下呢?该怎么接着获取下去?
      

  8.   

    Vista or later UIAutomation.MSTaskSwWClass 的子窗口模式只在 XP 下有用。
    Vista 之后就没有子窗口了。
      

  9.   

    是吗?
    能不能帖个例子,或者给个连接?我之前看过UIAutomation,但网上的例子很复杂,也没有调成功。