不建议用PostMessage或者SendMessage,你既然用了WB控件了,何不用获取WB网页中的元素并调用里面的方法事件进行自动操作呢,这样就简单多了

解决方案 »

  1.   

    HtmlDocument HDoc = frameWindow.Document;   //获取Frame中的网页Document
                    HtmlElement txtElement = HDoc.All["TxtTop"];    //搜索Document中的元素
                    if (txtElement != null)
                    {
                        MessageBox.Show(txtElement.Id);     //元素Id
                        MessageBox.Show(txtElement.Name);   //元素Name
                        MessageBox.Show(txtElement.OuterHtml);  //元素HTML代码
                        MessageBox.Show(txtElement.GetAttribute("value"));  //元素的属性值                    _processDemo.SetText(txtElement.GetAttribute("value")); //将元素的值发送到另一程序
                    }                HtmlElement lblElement = HDoc.All["q"]; //搜索Document中的元素
                    if (lblElement != null)
                    {
                        MessageBox.Show(lblElement.InnerText);  //获取此元素的文本
                    }
      

  2.   

    能加我QQ教教我么,QQ 89783100,或者我加你,你的多少?  我有点半懂半不懂的,一个网页中很多图片啊,而且这个小图片是点击后出现的,是找到这个图片的名字然后进行操作吗?
      

  3.   

    HtmlElement he = wb.Document.All["id"];
    he.InvokeMember("click");
      

  4.   

     _processDemo.SetText(txtElement.GetAttribute("value"));
    processDemo是什么?
      

  5.   

    那你给我的代码就是我先找出这个网页的元素,然后我找出该元素后这些代码就没用了?
    直接HtmlElement he = wb.Document.All["id"]; 
    he.InvokeMember("click");   (这个ID就是代表元素的名字吗?)
      

  6.   

    http://code.google.com/p/autotester/
      

  7.   

    然后就可以对应的去找方法了呀,
    System.Windows.Forms.HtmlElement   btn_Submit   =   this.webbrowser1.Document.GetElementById("Submit");  
    btn_Submit.InvokeMember("click"); 
    click是指里面的事件
      

  8.   

    如果要点击的是一个flash中的某个部分,怎么取元素?
      

  9.   

    如果你每次都能够知道要点击的坐标,那么很简单。        [DllImport("user32.dll")]
            static extern int mouse_event(int dwFlags, int dx, int dy, int cButtons, int dwExtraInfo);        const int MOUSEEVENTF_MOVE = 0x0001;        //移动鼠标
            const int MOUSEEVENTF_LEFTDOWN = 0x0002;    //模拟鼠标左键按下
            const int MOUSEEVENTF_LEFTUP = 0x0004;      //模拟鼠标左键抬起
            const int MOUSEEVENTF_RIGHTDOWN = 0x0008;   //模拟鼠标右键按下
            const int MOUSEEVENTF_RIGHTUP = 0x0010;     //模拟鼠标右键抬起
            const int MOUSEEVENTF_MIDDLEDOWN = 0x0020;  //模拟鼠标中键按下
            const int MOUSEEVENTF_MIDDLEUP = 0x0040;    //模拟鼠标中键抬起
            const int MOUSEEVENTF_ABSOLUTE = 0x8000;    //标示是否采用绝对坐标 Cursor.Position = pt;
    mouse_event(MOUSEEVENTF_RIGHTDOWN | MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0);
      

  10.   

    还是收发数据包简单啊
    HttpWebRequest 类
    HttpWebResponse 类
      

  11.   

    _processDemo.SetText(txtElement.GetAttribute("value")); 
    processDemo是什么? 前面的代码里 
      

  12.   

    试了下程序,其中private void button1_Click(object sender, EventArgs e)
            {
                HtmlElement he = webBrowser1.Document.All["close_button"];
                he.InvokeMember("click");        }
    说我最后一句话有异常,未将对象引用设置到对象的实例。什么回事?这个close_button是一个关闭按钮,当我点击button1时,鼠标点击关闭按钮,哪错了吗?
      

  13.   

    private void button1_Click(object sender, EventArgs e)
            {
                HtmlDocument doc = webBrowser1.Document;
                HtmlElementCollection elements = doc.All;
                foreach (HtmlElement element in elements)
                {
                    if (element.GetAttribute("type") == "hidden")
                    {
                        Console.WriteLine(element.GetAttribute("name"));
                        Console.WriteLine(element.GetAttribute("value"));
                    }
                }
            }
    当我输入上述代码时,程序告诉我请确保有足够的权限和确定该文件不止是只读,有什么方法解决么
      

  14.   

    不知道你的游戏是不是flash的。其实你完全可以用伪造数据的方法做外挂,自己这么模拟太累太麻烦。
      

  15.   

    我用了下这个方法,说我未将对象引用设置到对象的实例。什么回事?这个close_button是一个关闭按钮,当我点击button1时,鼠标点击关闭按钮,哪错了吗?