用于网易POPO聊天工具的自动回复类
/******************************************************************************
* COPYRIGHT NJAU LIMITED 2006
* File name : AutoPopo.cs
* Summary : For answering POPO autoly.
* Author : Cheng chong<mailvincent@163.com>
* History : 2004/12/12 - Version 1.0 First version.
******************************************************************************/
using System;
using System.Collections;
namespace AutoPoPo
{
/// <summary>
/// 用于网易POPO的自动回复AutoPoPo基础类
/// </summary>
public class AutoPoPo
{
public AutoPoPo()
{
}
public static int Autopopo( string AutoBackContent,ArrayList NoAutoList)
{
int retval = 0; //增加一个返回值用来判断操作是否成功
//下面的这些参数都可以用Spy++查到
string lpszParentClass = "NETEASE POPO UniformMsgWnd"; //整个窗口的类名
string lpszParentWindow = "";//"程冲-对话"; //窗口标题
string lpszClass ="ExtraEd"; //需要查找的子窗口的类名,也就是输入框
string lpszClass_Submit = "CuteButton"; //需要查找的Button的类名
string lpszName_Submit = ""; //需要查找的Button的标题
NativeWIN32.STRINGBUFFER sLimitedLengthWindowTitle;
IntPtr ParenthWnd = new IntPtr(0);
IntPtr EdithWnd = new IntPtr(0);
try
{
//查到窗体,得到整个窗体
EdithWnd =
NativeWIN32.FindWindowEx(ParenthWnd,EdithWnd,lpszParentClass,IntPtr.Zero);
if(!EdithWnd.Equals(IntPtr.Zero))
{
// 获取窗口标题
NativeWIN32.GetWindowText(EdithWnd, out sLimitedLengthWindowTitle, 256);
lpszParentWindow = sLimitedLengthWindowTitle.szText;
}
else
{
return retval;
}
string NameStr=lpszParentWindow.Replace("-对话","");
if(NoAutoList.Contains(NameStr)) return -1;//退出,不用自动回复
//获取对话框的窗口句柄
ParenthWnd = NativeWIN32.FindWindow(lpszParentClass,lpszParentWindow);
//判断这个窗体是否有效
if (!ParenthWnd.Equals(IntPtr.Zero))
{
EdithWnd = new IntPtr(0);
//得到User Name这个子窗体,并设置其内容
EdithWnd = NativeWIN32.FindWindowEx(ParenthWnd,EdithWnd,lpszClass,"");
//得到User Name这个子窗体,并设置其内容
EdithWnd = NativeWIN32.FindWindowEx(ParenthWnd,EdithWnd,lpszClass,"");
if (!EdithWnd.Equals(IntPtr.Zero))
{
//自动回复的内容
string tempStr=AutoBackContent;
char[] temp=tempStr.ToCharArray();
foreach(char tempChar in temp)
NativeWIN32.SendMessage(EdithWnd,NativeWIN32.WM_CHAR,(int)tempChar,0);
retval ++;
}
else
{
return 0;
}
#region 先顺序遍历两个对象CutePhoto
EdithWnd = NativeWIN32.FindWindowEx(ParenthWnd,EdithWnd,"CutePhoto","");
EdithWnd = NativeWIN32.FindWindowEx(ParenthWnd,EdithWnd,"CutePhoto","");
#endregion
//得到Button这个子窗体,并触发它的Click事件
EdithWnd =
NativeWIN32.FindWindowEx(ParenthWnd,
EdithWnd,lpszClass_Submit,lpszName_Submit);
if (!EdithWnd.Equals(IntPtr.Zero))
{
NativeWIN32.SendMessage(EdithWnd,
NativeWIN32.WM_LBUTTONDOWN,"0",(IntPtr)0);
NativeWIN32.SendMessage(EdithWnd,
NativeWIN32.WM_LBUTTONUP,"0",(IntPtr)0);
NativeWIN32.SendMessage(EdithWnd,NativeWIN32.WM_CLICK,"0",(IntPtr)0);
retval ++;
}
else
{
return 0;
}
//关闭窗口
EdithWnd = new IntPtr(0);
EdithWnd = NativeWIN32.FindWindowEx(ParenthWnd,EdithWnd,"CuteButton","");
EdithWnd = NativeWIN32.FindWindowEx(ParenthWnd,EdithWnd,"CuteButton","");
EdithWnd = NativeWIN32.FindWindowEx(ParenthWnd,EdithWnd,"CuteButton","");
if (!EdithWnd.Equals(IntPtr.Zero))
{
NativeWIN32.SendMessage
(EdithWnd,NativeWIN32.WM_LBUTTONDOWN,"0",(IntPtr)0);
NativeWIN32.SendMessage
(EdithWnd,NativeWIN32.WM_LBUTTONUP,"0",(IntPtr)0);
NativeWIN32.SendMessage(EdithWnd,NativeWIN32.WM_CLICK,"0",(IntPtr)0);
retval ++;
}
else
{
return 0;
}
}
AutoMessage.POPOHisStr=lpszParentWindow;
return retval;
}
catch(Exception ex)
{
throw(new Exception(ex.Source+ex.Message));
}
}
}
}
* COPYRIGHT NJAU LIMITED 2006
* File name : AutoPopo.cs
* Summary : For answering POPO autoly.
* Author : Cheng chong<mailvincent@163.com>
* History : 2004/12/12 - Version 1.0 First version.
******************************************************************************/
using System;
using System.Collections;
namespace AutoPoPo
{
/// <summary>
/// 用于网易POPO的自动回复AutoPoPo基础类
/// </summary>
public class AutoPoPo
{
public AutoPoPo()
{
}
public static int Autopopo( string AutoBackContent,ArrayList NoAutoList)
{
int retval = 0; //增加一个返回值用来判断操作是否成功
//下面的这些参数都可以用Spy++查到
string lpszParentClass = "NETEASE POPO UniformMsgWnd"; //整个窗口的类名
string lpszParentWindow = "";//"程冲-对话"; //窗口标题
string lpszClass ="ExtraEd"; //需要查找的子窗口的类名,也就是输入框
string lpszClass_Submit = "CuteButton"; //需要查找的Button的类名
string lpszName_Submit = ""; //需要查找的Button的标题
NativeWIN32.STRINGBUFFER sLimitedLengthWindowTitle;
IntPtr ParenthWnd = new IntPtr(0);
IntPtr EdithWnd = new IntPtr(0);
try
{
//查到窗体,得到整个窗体
EdithWnd =
NativeWIN32.FindWindowEx(ParenthWnd,EdithWnd,lpszParentClass,IntPtr.Zero);
if(!EdithWnd.Equals(IntPtr.Zero))
{
// 获取窗口标题
NativeWIN32.GetWindowText(EdithWnd, out sLimitedLengthWindowTitle, 256);
lpszParentWindow = sLimitedLengthWindowTitle.szText;
}
else
{
return retval;
}
string NameStr=lpszParentWindow.Replace("-对话","");
if(NoAutoList.Contains(NameStr)) return -1;//退出,不用自动回复
//获取对话框的窗口句柄
ParenthWnd = NativeWIN32.FindWindow(lpszParentClass,lpszParentWindow);
//判断这个窗体是否有效
if (!ParenthWnd.Equals(IntPtr.Zero))
{
EdithWnd = new IntPtr(0);
//得到User Name这个子窗体,并设置其内容
EdithWnd = NativeWIN32.FindWindowEx(ParenthWnd,EdithWnd,lpszClass,"");
//得到User Name这个子窗体,并设置其内容
EdithWnd = NativeWIN32.FindWindowEx(ParenthWnd,EdithWnd,lpszClass,"");
if (!EdithWnd.Equals(IntPtr.Zero))
{
//自动回复的内容
string tempStr=AutoBackContent;
char[] temp=tempStr.ToCharArray();
foreach(char tempChar in temp)
NativeWIN32.SendMessage(EdithWnd,NativeWIN32.WM_CHAR,(int)tempChar,0);
retval ++;
}
else
{
return 0;
}
#region 先顺序遍历两个对象CutePhoto
EdithWnd = NativeWIN32.FindWindowEx(ParenthWnd,EdithWnd,"CutePhoto","");
EdithWnd = NativeWIN32.FindWindowEx(ParenthWnd,EdithWnd,"CutePhoto","");
#endregion
//得到Button这个子窗体,并触发它的Click事件
EdithWnd =
NativeWIN32.FindWindowEx(ParenthWnd,
EdithWnd,lpszClass_Submit,lpszName_Submit);
if (!EdithWnd.Equals(IntPtr.Zero))
{
NativeWIN32.SendMessage(EdithWnd,
NativeWIN32.WM_LBUTTONDOWN,"0",(IntPtr)0);
NativeWIN32.SendMessage(EdithWnd,
NativeWIN32.WM_LBUTTONUP,"0",(IntPtr)0);
NativeWIN32.SendMessage(EdithWnd,NativeWIN32.WM_CLICK,"0",(IntPtr)0);
retval ++;
}
else
{
return 0;
}
//关闭窗口
EdithWnd = new IntPtr(0);
EdithWnd = NativeWIN32.FindWindowEx(ParenthWnd,EdithWnd,"CuteButton","");
EdithWnd = NativeWIN32.FindWindowEx(ParenthWnd,EdithWnd,"CuteButton","");
EdithWnd = NativeWIN32.FindWindowEx(ParenthWnd,EdithWnd,"CuteButton","");
if (!EdithWnd.Equals(IntPtr.Zero))
{
NativeWIN32.SendMessage
(EdithWnd,NativeWIN32.WM_LBUTTONDOWN,"0",(IntPtr)0);
NativeWIN32.SendMessage
(EdithWnd,NativeWIN32.WM_LBUTTONUP,"0",(IntPtr)0);
NativeWIN32.SendMessage(EdithWnd,NativeWIN32.WM_CLICK,"0",(IntPtr)0);
retval ++;
}
else
{
return 0;
}
}
AutoMessage.POPOHisStr=lpszParentWindow;
return retval;
}
catch(Exception ex)
{
throw(new Exception(ex.Source+ex.Message));
}
}
}
}