本帖最后由 u011321421 于 2013-11-15 12:57:24 编辑

解决方案 »

  1.   

    可以输入啊,而且根本不需要定位焦点啊。            if (WB1.Document.GetElementById("password") != null)
                {
                    WB1.Document.GetElementById("nick").SetAttribute("value", "aaabbbccc");
    //                WB1.Document.GetElementById("nick").Focus();                WB1.Document.GetElementById("password").SetAttribute("value", "xxxxxxxxxx");
    //                WB1.Document.GetElementById("password").Focus();                WB1.Document.GetElementById("password_again").SetAttribute("value", "xxxxxxxxxxx");
    //                WB1.Document.GetElementById("password_again").Focus();                this.WB1.Document.GetElementById("year_11").InvokeMember("Click");
                    this.WB1.Document.GetElementById("month_5").InvokeMember("Click");
                    this.WB1.Document.GetElementById("day_6").InvokeMember("Click");                if (WB1.Document.GetElementById("code") != null)
                    {
    //                    WB1.Document.GetElementById("code").Focus();
                        WB1.Document.GetElementById("code").SetAttribute("value", "aaaaaaaaaaaaa");
                    }            }
      

  2.   


    不处理焦点你确定能注册成功??
    这一句:webQQReq.Document.GetElementById("nick").Focus();
    注释了的话,点击注册时会提示【昵称不能为空】
    而且无法在webbrowser控件中的文本框输入验证码,只能通过winform上控件的文本框赋值。通过抓包发现了,“抢焦点”是激发了某个事件导致不断地向服务器请求数据:
      

  3.   

    你提的问题是抢焦点无法输入验证码,我给的代码已经可以输入验证码了,只是还无法完成注册的问题;
    不过你已经找到部分原因了,昵称和密码那里要setfocus()才不会提示为空;
    最重要的是年月日那里会不断的跳,我想原因是它可能要判断 是否闰年、某月多少天之类的逻辑,当然也要用setfocus,但是不能连续点击,要给它一定的响应时间,加上Application.DoEvents();就可以了。            if (WB1.Document.GetElementById("password") != null)
                {
                    WB1.Document.GetElementById("nick").SetAttribute("value", "aaabbbccc");
                   WB1.Document.GetElementById("nick").Focus();                WB1.Document.GetElementById("password").SetAttribute("value", "xxx123");
                    WB1.Document.GetElementById("password").Focus();                WB1.Document.GetElementById("password_again").SetAttribute("value", "xxx123");
                    WB1.Document.GetElementById("password_again").Focus();                this.WB1.Document.GetElementById("year_11").InvokeMember("Click");
                    this.WB1.Document.GetElementById("year_11").Focus();
                    Application.DoEvents();
                    this.WB1.Document.GetElementById("month_5").InvokeMember("Click");
                    this.WB1.Document.GetElementById("month_5").Focus();
                    Application.DoEvents();
                    this.WB1.Document.GetElementById("day_6").InvokeMember("Click");
                    this.WB1.Document.GetElementById("day_6").Focus();
                    Application.DoEvents();                if (WB1.Document.GetElementById("code") != null)
                    {
                       WB1.Document.GetElementById("code").Focus();
                        WB1.Document.GetElementById("code").SetAttribute("value", txtcode.Text);
                    }            }
                WB1.Document.GetElementById("submit").InvokeMember("Click");上面的代码经过亲测,一次通过注册,直接就调到输入手机号那里了!