Compile a Windows form application in C #ProgramTo automatically log on to a specific page.
The following uses automatic login: http://bm.chinaz.com/Web/Login.aspx as an example, explains how to simulate manually enter the user name and password and click Login, to achieve automatic login.
Create a new C # application, give the application a name, such as autologin, add a Textbox, button, and webbrowser control to the form, and add a webbrowser1_documentcompleted event to the webbrowser control.
Click Event of the button andCodeAs follows:
Private void btn_add_click (Object sender, eventargs e) {string Surl = txb_url.text.trim (); If (Surl. length> 0) {webbrowser1.navigate (Surl) ;}} private void webbrowserappsdocumentcompleted (Object sender, webbrowserdocumentcompletedeventargs e) {htmlelement clickbtn = NULL; If (E. URL. tostring (). tolower (). indexof ("login. aspx ")> 0) {htmldocument Doc = webbrowser1.document; For (INT I = 0; I <Doc. all. count; I ++) {If (Doc. all [I]. tagname. toupper (). equals ("input") {Switch (Doc. all [I]. name) {Case "txtusername": Doc. all [I]. innertext = "xxxx@yy.com"; // user name break; Case "txtpassword": Doc. all [I]. innertext = "zzzzzzzz"; // password break; Case "btnsubmit": clickbtn = Doc. all [I]; break ;}} clickbtn. invokemember ("click"); // click the "Log on" button }}
when you enter the http://bm.chinaz.com/Web/Login.aspx In the textbox and click the button, you can achieve automatic login page.