简体   繁体   English

Winforms Web浏览器捕获登录的表单详细信息

[英]winforms web browser capturing form details for a login

I want to make a app that allows me to use a web browser component in a winforms so that a user can save the login details for a site. 我想制作一个允许我在Winforms中使用Web浏览器组件的应用程序,以便用户可以保存网站的登录详细信息。

Assume that the webbrowser takes a url entered by the user, they have a login page, user and password and a button 假设网络浏览器接受用户输入的网址,他们有一个登录页面,用户名和密码以及一个按钮

I want to store all this information and then allow the user to fire up their default browser using the stored login information. 我想存储所有这些信息,然后允许用户使用存储的登录信息启动其默认浏览器。

    private void button3_Click(object sender, EventArgs e)
    {
        IHTMLDocument2 htmlDocument = webBrowser1.Document.DomDocument as IHTMLDocument2;

        IHTMLElement activeElement = htmlDocument.activeElement;

        if (activeElement != null)
        {

           txt_password.Text = activeElement.id;
           txt_password_value.Text = (activeElement.innerText);

        }
    }

I can store the name of the user and password fields but cant capture the text in the current form from the method above. 我可以存储用户名和密码字段的名称,但是无法通过上述方法捕获当前表单中的文本。

I also am struggling to capture the button on the form, 我也在努力捕捉表单上的按钮,

Is it a good idea to have some kind of function that highlights any dom element with a red border when the mouse hovers over it (only for textboxes, buttons) so that they can right click it and store this information for their auto login? 当鼠标悬停在dom元素上时,具有某种功能以红色边框突出显示dom元素(仅适用于文本框,按钮),以便他们可以右键单击并存储此信息以进行自动登录,是否是一个好主意?

Later I need to also work out how to launch the default browser using the stored information 稍后我还需要弄清楚如何使用存储的信息启动默认浏览器

Yes I have already developed a firefox plugin to do this, and chrome and IE but I really need to do it this way somehow! 是的,我已经开发了一个firefox插件以及chrome和IE,但是我确实需要以某种方式这样做!

  IHTMLElementCollection hTMLInputElementCollection = tag.getElementsByTagName("input");

            //All input tag such as Textbox , Radiobutton , Checkbox

            foreach (HTMLInputElement elInput in hTMLInputElementCollection)
            {

                switch (elInput.id)
                {
                    case "txtusername":
                        elInput.value = "";
                        break;
                    case "txtpassword":
                        elInput.value = "";
                        break;
                    case "btnlogin":
                        elInput.click();
                        break;
                }
            }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM