点击开一个QQ群.里面有个发信息的.输入内容的那个控件的句柄怎么这难找?登陆按钮的句柄我都找到了.就差那个输入文本框的句柄了 int nTime = 75;
string search="广告/设计类招聘群 - 群";
int QunWnd = 0;
int currentHandle = 0;
//找QQ登陆句柄
while (nTime-- > 0)
{
QunWnd= FindWindow("#32770",search);
if (QunWnd != 0)
{
break;
}
System.Threading.Thread.Sleep(50);
}
if (QunWnd == 0)
{
MessageBox.Show("窗体没有没找到,请重试");
return;
}
//找QQ群输入文本框
currentHandle = DelayFindWindowEx(QunWnd,0,"#32770","");
if (currentHandle != 0)
{
currentHandle = DelayFindWindowEx(currentHandle,0,"RICHEDIT","");//密码
if (currentHandle != 0)
{
string say ="大家好";
SendMessage(currentHandle, WM_SETTEXT, 0,say);
}
}

解决方案 »

  1.   

    技术交流群号:23266021
    欢迎大家在此讨论关于.net的各种技术。
      

  2.   

    我发现该输入框在. afxWnd42下.但是它的子窗口的句柄是不同的?关了打开又不同了?
    求.怎么遍历该afxWnd42下的子窗体?
      

  3.   

    已经找到了.但给richedit给值的时候,发现sendmessage不行.用sendmessage给值给edit就可以.为什么呢?
      

  4.   

    已经找到了.但给richedit给值的时候,发现sendmessage不行.用sendmessage给值给edit就可以.为什么呢?
      

  5.   

    技术交流群号:23266021
    欢迎大家在此讨论关于.net的各种技术。1号群
      

  6.   

    QQ中直接用sendmessage中的WM_SETTEXT 给值是不行的.要WM_PASTE才行.有没具体人操作过?
      

  7.   

    我做过,发送WM_SETTEXT,WM_PASTE是不行的,你发EM_REPLACESEL吧,一定OK
    我做过QQ尾程序的一部份
    SendMessage(hdo,EM_SETSEL,-1,-1);//hdo-Handle of richtext,move to the end of richtext
    StringBuilder sb=new StringBuilder(256);
    sb.Append("your text to append");
    SendMessage(hdo,EM_REPLACESEL,0,sb);