.net控制网页

/// <summary>
        /// 登录 CNC 宽视界。
        /// </summary>
        public void go_cnc()
        {
            InternetExplorer ie = new InternetExplorer();
            ie.Visible = true;

            object nil = null;
            //引导到URL
            ie.Navigate("http://eeye.online.tj.cn/main/login.asp", ref nil, ref nil, ref nil, ref nil);

            while (ie.ReadyState != tagREADYSTATE.READYSTATE_COMPLETE)
            {
                Thread.Sleep(10);
            }

            // 获取登录表单。
            IHTMLDocument2 doc = (IHTMLDocument2)ie.Document;
            // 帐号赋值。
            IHTMLInputTextElement uidInput = (IHTMLInputTextElement)doc.all.item("uid", null);
            uidInput.value = "mzbz_admin";
            // 密码赋值。
            IHTMLInputTextElement pwdInput = (IHTMLInputTextElement)doc.all.item("pwd", null);
            pwdInput.value = "888888";

            // 提交表单。
            doc.parentWindow.execScript("onSubmit()", "javascript");

            bool quit = false;
            ie.OnQuit += delegate()
            {
                quit = true;
            };

            while (quit)
            {
                Thread.Sleep(10);
            }
        }

posted @ 2009-04-07 09:07  清晖皓月  阅读(241)  评论(0编辑  收藏  举报