private void Button_Click_1(object sender, RoutedEventArgs e)
{
richHandle = IntPtr.Zero;
EnumWindows(EnumFunc, 0);
if (richHandle == IntPtr.Zero)
return;
Console.WriteLine(Process_ReadRichEditText(richHandle));
} public bool EnumFunc(IntPtr hwnd, int lParam)
{
if (!IsWindowVisible(hwnd))
return true; // 不可见 StringBuilder vBuffer = new StringBuilder(256);
GetClassName(hwnd, vBuffer, vBuffer.Capacity);
string name = vBuffer.ToString();
if (vBuffer.ToString() == "TXGuiFoundation")
{
uint vProcessId; GetWindowThreadProcessId(hwnd, out vProcessId);
var nameid = GetProcessName(vProcessId).ToLower();
if (GetProcessName(vProcessId).ToLower() == "qq.exe")
{
GetWindowText(hwnd, vBuffer, vBuffer.Capacity);
// 标题中含"聊天中"
if (vBuffer.ToString().IndexOf("杜老师") >= 0)
{
//在这里应该是要找这个窗体里面的控件才对啊?为什么这里是枚举他的子窗口?
//还有他这里不会进入@EnumChild方法,我想是因为他找不到这个子窗口的原因?
//那这里怎么来枚举这个窗体的所有控件呢?
//谢谢
EnumChildWindows(hwnd, @EnumChild, lParam);
return false;
}
}
}
return true;
}
我上面用: EnumWindows(EnumFunc, 0); 方法来得到所有窗体
然后在EnumFunc中判断窗体类型是否为:TXGuiFoundation且进程为"qq.exe"
如果是的话判断QQ聊天窗体的标题是否为有:“杜老师”
如果有的话,我就要“枚举这个窗体的所有控件”,来找到聊天输入框
但是现在,我不知道旧城改造以来“枚举这个窗体的所有控件”谢谢
{
richHandle = IntPtr.Zero;
EnumWindows(EnumFunc, 0);
if (richHandle == IntPtr.Zero)
return;
Console.WriteLine(Process_ReadRichEditText(richHandle));
} public bool EnumFunc(IntPtr hwnd, int lParam)
{
if (!IsWindowVisible(hwnd))
return true; // 不可见 StringBuilder vBuffer = new StringBuilder(256);
GetClassName(hwnd, vBuffer, vBuffer.Capacity);
string name = vBuffer.ToString();
if (vBuffer.ToString() == "TXGuiFoundation")
{
uint vProcessId; GetWindowThreadProcessId(hwnd, out vProcessId);
var nameid = GetProcessName(vProcessId).ToLower();
if (GetProcessName(vProcessId).ToLower() == "qq.exe")
{
GetWindowText(hwnd, vBuffer, vBuffer.Capacity);
// 标题中含"聊天中"
if (vBuffer.ToString().IndexOf("杜老师") >= 0)
{
//在这里应该是要找这个窗体里面的控件才对啊?为什么这里是枚举他的子窗口?
//还有他这里不会进入@EnumChild方法,我想是因为他找不到这个子窗口的原因?
//那这里怎么来枚举这个窗体的所有控件呢?
//谢谢
EnumChildWindows(hwnd, @EnumChild, lParam);
return false;
}
}
}
return true;
}
我上面用: EnumWindows(EnumFunc, 0); 方法来得到所有窗体
然后在EnumFunc中判断窗体类型是否为:TXGuiFoundation且进程为"qq.exe"
如果是的话判断QQ聊天窗体的标题是否为有:“杜老师”
如果有的话,我就要“枚举这个窗体的所有控件”,来找到聊天输入框
但是现在,我不知道旧城改造以来“枚举这个窗体的所有控件”谢谢
解决方案 »
- winform窗体隐藏问题,为什么会同时被隐藏?高秀帮帮忙
- ◆◆◆◇VS2003转换到2005后,OpenFileDialog错误,急!!!
- 关于一个SQL的问题.
- 自己通过httpwebrequest类做了个灌水机,但程序运行起来超卡
- 倒霉啊,老板要我做一个对PDF文件进行注释的程序,也就是说看到哪里,就可以当场在文件上标注并保存
- 为什么我的DataList显示不了
- 不好意思,我是新手. 请教各位老大哥,怎样在C#下读取文本文件中的数值数据,并传给excel!!多谢了
- 请教:web 页上显示数据图表的方法?
- 请问,如何用 c# 程序实现 在 IIS 服务器设置里面,HTTP 头,mime 添加文件类型 比如 .exe 等类型
- 问个关于System.xml的问题?(pie9912)
- 新手求教,用C#如何对oracle数据库进行增删改查?
- 为什么程序没有将改动写入文件,求高手指点
我发现WPF写的程序WINAPI也得不到句柄
{
AutomationElement desktop = AutomationElement.RootElement;
AutomationElement QQwindow = desktop.FindFirst(TreeScope.Children, new AndCondition(
new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Window),
new PropertyCondition(AutomationElement.NameProperty, "对方昵称")));
AutomationElement QQedit = QQwindow.FindFirst(TreeScope.Subtree, new AndCondition(
new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Edit),
new PropertyCondition(AutomationElement.LocalizedControlTypeProperty, "编辑")));
return ((ValuePattern)QQedit.GetCurrentPattern(ValuePattern.Pattern)).Current.Value;
}
试了下WPF的程序,也可以轻松获取
才知道有这个东东, 似乎很牛X的样子, 谢谢啊。
他里面调的API都是公开的吗?
是啊,这个.net自带的库,很好用,不过很多人不知道,还在用win32api获取窗体,该库不是一般的强大