关于FindWindow和FindWindowEx获取任务栏子窗口的方法。 本帖最后由 lgjgsslgjgss 于 2012-07-10 08:24:08 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 XP系统层次:Shell_TrayWnd-->ReBarWindow32-->MSTaskSwWClass-->ToolbarWindow32 我用下面也是不行。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 ); } 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 ); 你的代码里,最终handle2是什么? 什么意思?你的代码里,handle2是什么窗体(就是说,是哪个可视区域)的句柄? 是吗?我在xp下,handle3是零啊。 是的,我搞错了。你是正确的,2楼的代码,在xp下是没有问题的。那么,在win7下呢?该怎么接着获取下去? Vista or later UIAutomation.MSTaskSwWClass 的子窗口模式只在 XP 下有用。Vista 之后就没有子窗口了。 是吗?能不能帖个例子,或者给个连接?我之前看过UIAutomation,但网上的例子很复杂,也没有调成功。 DataAdapter类的使用,向数据源新增数据 一个C#小问题:怎么从DataRow 类型的转化成float类型 求个正则表达式 关于[]的问题!!!!!!!谢谢解答 帮忙写个小程序(10分钟)电脑没装.net 为何从数据库中读取会出错? 怎么样将textbox里面的text传入对象数组中? 请问this.Hide,this.Close,this.Dispose使用区别 如何将From的标题栏去掉? 急! EXE文件的图标 视觉密码(VisualCrypto) 取出 "xxxxxxAxxxxxBxxxxx" AB之间的字符串有些什么方法
Shell_TrayWnd-->ReBarWindow32-->MSTaskSwWClass-->ToolbarWindow32
[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 );
}
int handle1 = FindWindowEx(handle0, 0, "ReBarWindow32", null);
int handle2 = FindWindowEx(handle1, 0, "ToolbarWindow32", null);
this.Title = ( handle0 + " " + handle1 + " " + handle2 );
你的代码里,最终handle2是什么?
什么意思?你的代码里,handle2是什么窗体(就是说,是哪个可视区域)的句柄?
是的,我搞错了。你是正确的,2楼的代码,在xp下是没有问题的。
那么,在win7下呢?该怎么接着获取下去?
Vista 之后就没有子窗口了。
能不能帖个例子,或者给个连接?我之前看过UIAutomation,但网上的例子很复杂,也没有调成功。