如何获取一个 第三方窗口 中的相关控件信息? 可以利用api获得当前窗口的资源! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我也是这么想的,但如何能准确获得 窗口中的资源?虽然可以用FindWindow()找到某标题的窗口,但再用FindWindowEx()继续查找该窗口中的某个资源的ID时,却不成功,如我例中的“确定”,我的部份代码如下:例:[DllImport("user32.dll")]public static extern IntPtr FindWindow(string lpClassName, string lpWindowName); [DllImport("user32.dll")]public static extern IntPtr FindWindowEx(IntPtr hwndParent,IntPtr hwndChildAfter,string lpszClass,string lpszWindow);[DllImport("user32.dll",CharSet=CharSet.Unicode)] public static extern IntPtr PostMessage(IntPtr hwnd,int wMsg,IntPtr wParam,IntPtr lParam);IntPtr hwnd_textbox;string strtext; hwnd_win = FindWindow(null, this.textBox9.Text.Trim());if (hwnd_win == IntPtr.Zero) { MessageBox.Show("警告:找不到目标窗口:" + this.textBox9.Text.Trim()); return; } //this.textBox10.Text.Trim()是我指定窗口中的某个资源,如“确定”,textBox1等 hwnd_textbox = FindWindowEx(hwnd_win, new IntPtr(0), null, this.textBox10.Text.Trim()); 你试试,用反射把dll里的类的属性,方法等信息给搞出来。或者,直接用ildasm.exe把第三方窗口的dll的中间语言代码给显示出来,再研究一下! jingxijun(大梦)已经说得很清楚了,使用api函数,得到窗体的handle,然后再得到窗体上面控件的handle,然后postmessage就行了。我们单位的100多台电脑瑞星升级就是我这么做的。你还可以使用程序间谍这个软件察看窗体的名称,控件的名称……。然后就自己做了。 恕俺水平低凹:"使用api函数,得到窗体的handle,然后再得到窗体上面控件的handle,然后postmessage就行了"中的 窗体handle可以根据窗体名称容易求得,但困难就是如何求得该窗体上的某个控件的handle,若知道了此handle也可以容易postmessage了。“程序间谍”:能否告诉下载地址? 谢谢。程序间谍和SPY++差不多,好象没用 用api获得当前窗口的资源不可以吗? 关于DataGridView下拉列表的问题。 一个正则的问题。。。。。。。 有关Debug和Release的问题 winform 如何给radiobutton 设置值? axWebBrowser 是非受托管的控件,所以不能运行于智能客户端,那我在智能客户端中如何才能允许打开一个网页呢? 算术运算中发生溢出或下溢 再开一贴,请看清SQLSERVER 关于menuStrip控件的问题 文件写操作问题 改变先祖的工具栏图标,继承窗体在设计时也跟着变了,可是为什么运行时,还是以前的样子? 求救!!! 关于windows服务 timespan的问题
虽然可以用FindWindow()找到某标题的窗口,但再用FindWindowEx()
继续查找该窗口中的某个资源的ID时,却不成功,如我例中的“确定”,
我的部份代码如下:例:
[DllImport("user32.dll")]
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll")]
public static extern IntPtr FindWindowEx(IntPtr hwndParent,IntPtr hwndChildAfter,string lpszClass,string lpszWindow);[DllImport("user32.dll",CharSet=CharSet.Unicode)]
public static extern IntPtr PostMessage(IntPtr hwnd,int wMsg,IntPtr wParam,IntPtr lParam);IntPtr hwnd_textbox;
string strtext; hwnd_win = FindWindow(null, this.textBox9.Text.Trim());
if (hwnd_win == IntPtr.Zero)
{
MessageBox.Show("警告:找不到目标窗口:" + this.textBox9.Text.Trim());
return;
}
//this.textBox10.Text.Trim()是我指定窗口中的某个资源,如“确定”,textBox1等
hwnd_textbox = FindWindowEx(hwnd_win, new IntPtr(0), null, this.textBox10.Text.Trim());
"使用api函数,得到窗体的handle,然后再得到窗体上面控件的handle,然后postmessage就行了"中的 窗体handle可以根据窗体名称容易求得,但困难就是如何求得该窗体上的某个控件
的handle,若知道了此handle也可以容易postmessage了。
“程序间谍”:能否告诉下载地址?
程序间谍和SPY++差不多,好象没用