private void axWebBrowser1_DocumentComplete(object sender, AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEvent e) { doc = (mshtml.HTMLDocument)axWebBrowser1.Document; mshtml.HTMLDocumentEvents2_Event iEvent; iEvent = (mshtml.HTMLDocumentEvents2_Event) doc; iEvent.oncontextmenu+=new mshtml.HTMLDocumentEvents2_oncontextmenuEventHandler(ContextMenuEventHandler); }
private void webBrowser_LoadCompleted(object sender, NavigationEventArgs e) { mshtml.HTMLDocument doc; doc = (mshtml.HTMLDocument)_webBrowser.Document; mshtml.HTMLDocumentEvents2_Event iEvent; //Event in the mshtml Document through which mouse events can be raised. iEvent = (mshtml.HTMLDocumentEvents2_Event)doc; //iEvent.onclick += new mshtml.HTMLDocumentEvents2_onclickEventHandler(ClickEventHandler); //iEvent.onmousemove = if (_dwMouseMoveEventHandler != null) iEvent.onmousemove -= _dwMouseMoveEventHandler; _dwMouseMoveEventHandler = new mshtml.HTMLDocumentEvents2_onmousemoveEventHandler(MouseMoveEventHandler); iEvent.onmousemove += _dwMouseMoveEventHandler; }
private void WebBrowserLoadCompleted(object sender, NavigationEventArgs e) { System.Diagnostics.Debug.WriteLine("WebBrowserLoadCompleted"); var browser = sender as WebBrowser; if (browser == null || browser.Document == null) { return; } dynamic document = browser.Document; if (document.readyState != "complete") { return; } mshtml.HTMLDocument hdoc = document as mshtml.HTMLDocument; }
private void getData(mshtml.HTMLDocument doc) { mshtml.IHTMLElement grid = doc.getElementById("Gridvotacion"); List <string> datos = iterateTable(grid.innerHTML); cedula.Text = doc.getElementById("lblcedula").innerText; edad.Text = doc.getElementById("lbledad").innerText; nombre.Text = doc.getElementById("lblnombrecompleto").innerText; conocido.Text = doc.getElementById("lblconocidocomo").innerText; fecha.Text = doc.getElementById("lblfechaNacimiento").innerText; madre.Text = doc.getElementById("lblnombremadre").innerText; cedulaMadre.Text = doc.getElementById("lblid_madre").innerText; padre.Text = doc.getElementById("lblnombrepadre").innerText; cedulaPadre.Text = doc.getElementById("lblid_padre").innerText; nacionalidad.Text = doc.getElementById("lblnacionalidad").innerText; marginal.Text = doc.getElementById("lblLeyendaMarginal").innerText; provincia.Text = datos[0]; canton.Text = datos[1]; distrito.Text = datos[2]; }
private void tsbtnFill_Click(object sender, EventArgs e) { if (strMode != "Unknown") { SHDocVw.ShellWindows swTemp = new SHDocVw.ShellWindows(); Boolean boolTargetFound = false; Boolean boolTargetReady = false; EFilingDAL dal = new EFilingDAL(); try { foreach (SHDocVw.InternetExplorer ieTemp in swTemp) { string strDocName = dal.GetDocName(ieTemp.LocationURL.ToString().ToLower(), strYA); if (strDocName.Length > 0) { boolTargetFound = true; if (ieTemp.ReadyState.Equals(SHDocVw.tagREADYSTATE.READYSTATE_COMPLETE)) { boolTargetReady = true; if (typeof(mshtml.HTMLDocumentClass).IsAssignableFrom(ieTemp.Document.GetType())) { mshtml.HTMLDocument htmlDoc = ieTemp.Document as mshtml.HTMLDocument; ProcessDocument(htmlDoc); } } } } if (boolTargetFound == false) { MessageBox.Show("No relevant document is found for E-Filling!", "TAXcom E-Filing", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else if (boolTargetFound == true && boolTargetReady == false) { MessageBox.Show("Document is not ready, please try again!", "TAXcom E-Filing", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } }
public void ProcessDocument(mshtml.HTMLDocument htmlDoc) { switch (this.strYA) { case "2008": ProcessFormHK62008(htmlDoc); break; case "2009": ProcessFormHK62009(htmlDoc); break; case "2010": ProcessFormHK62010(htmlDoc); break; //LEESH FEB 2012 case "2011": ProcessFormHK62011(htmlDoc); break; //LEESH END case "2012": ProcessFormHK62012(htmlDoc); break; //simkh 2014 case "2013": ProcessFormHK62013(htmlDoc); break; //simk end case "2014": ProcessFormHK62014(htmlDoc); break; case "2015": ProcessFormHK62015(htmlDoc); break; } }
public void loadFromDB() { if (pform == null) { return; } dbTemplateForm dbt = new dbTemplateForm(); dbt.ShowDialog(); if (dbt.sel_template != null) { this.name = dbt.sel_template[0]; string html = dbt.sel_template[1]; this.description = dbt.sel_template[2]; IfacesEnumsStructsClasses.IHTMLDocument2 doc = pform.cEXWB1.GetActiveDocument(); mshtml.HTMLDocument docc = (mshtml.HTMLDocument)doc; // Encoding ec = Encoding.GetEncoding("gb2312"); // html = ec.GetString(System.Text.Encoding.Default.GetBytes(html)); string tempfilepath = Application.StartupPath; if (!tempfilepath.EndsWith("\\")) { tempfilepath = tempfilepath + "\\"; } tempfilepath = tempfilepath + "tempFile.html"; System.IO.File.WriteAllText(tempfilepath, html, Encoding.GetEncoding("gb2312")); /// docc.documentElement.innerHTML = html; // docc.body.outerHTML = "<body><label>a</label></body>"; this.setDocNameDesp(); pform.cEXWB1.Navigate(tempfilepath); } }
private HtmlElementUrl FindHtmlElement(string url) { mshtml.HTMLDocument doms = (mshtml.HTMLDocument)browser.clientBrowser.Document; var linkList = doms.links; foreach (var item in linkList) { var linkItem = ((mshtml.IHTMLAnchorElement)item); var scrollItem = ((mshtml.IHTMLElement2)item); var href = linkItem.href; if (href.Contains(url)) { return(new HtmlElementUrl() { Url = href, ScrollHeigt = scrollItem.scrollHeight }); } } return(null); }
public static string PRAP_GetProviderInfo(SHDocVw.InternetExplorer wb, SHDocVw.ShellWindows shells, string Type, string DCN) { /* * This is to return the single string listed (null or valid) in PRAP's claim inquiry details screen * Parameters are as follows: * WB: current valid shdocvw.internet explorer object * Shells: current shdocvw Shellwindows * Type: must be the exact field you're looking for in the provider tab. e.g. "Rendering Provider NPI:" * DCN: must be the full DCN number. e.g. 02018888888888x */ mshtml.HTMLDocument wbDoc = wb.Document; int p = 0; wbDoc = wb.Document; foreach (mshtml.IHTMLElement a in wbDoc.getElementsByTagName("a")) { if (a.innerText == "Provider") { a.click(); } } //IELib.IeWait(wb); if (Type != null) { foreach (mshtml.IHTMLElement a in wbDoc.getElementsByTagName("td")) { if (p == 1) { Console.WriteLine("returnd: " + a.innerText); return(a.innerText); } if (a.innerText == Type) { p = 1; } } } return(null); }
public static string PRAP_GetOnsetDate(SHDocVw.InternetExplorer wb, SHDocVw.ShellWindows shells) { mshtml.HTMLDocument wbDoc = wb.Document; int p = 0; foreach (mshtml.IHTMLElement td in wbDoc.getElementsByTagName("td")) { if (p == 1) { //Console.WriteLine("PRAP Auth: " + td.innerText); return(td.innerText); } if (td != null) { if (td.innerText == "Onset Date:") { p = 1; } } } return(null); }
public static void PRAP_ResetSearch(SHDocVw.InternetExplorer wb, SHDocVw.ShellWindows shells) { wb.Quit(); foreach (SHDocVw.InternetExplorer ie in shells) { if (ie.LocationName == "Search Results") { wb = IELib.IEGet(shells, "Search Results"); if (wb != null) { mshtml.HTMLDocument wbDoc = wb.Document; foreach (mshtml.IHTMLElement elem in wbDoc.getElementsByTagName("a")) { if (elem.innerText == "Return to Search") { elem.click(); IELib.IeWait(ie); } } } } } }
// get the selected range object public static HtmlTextRange GetTextRange(HtmlDocument document) { // define the selected range object HtmlSelection selection; HtmlTextRange range = null; try { // calculate the text range based on user selection selection = document.selection; if (selection.type.Equals("text", StringComparison.OrdinalIgnoreCase) || selection.type.Equals("none", StringComparison.OrdinalIgnoreCase)) { range = selection.createRange() as HtmlTextRange; } } catch (Exception) { // have unknown error so set return to null range = null; } return(range); }
// obtains a control range to be worked with public static HtmlControlRange GetAllControls(HtmlDocument document) { // define the selected range object HtmlSelection selection; HtmlControlRange range = null; try { // calculate the first control based on the user selection selection = document.selection; if (selection.type.Equals("control", StringComparison.OrdinalIgnoreCase)) { range = selection.createRange() as HtmlControlRange; } } catch (Exception) { // have unknow error so set return to null range = null; } return(range); }
private void Try_to_send_message() { mshtml.HTMLDocument doc = (mshtml.HTMLDocument)Main_Web.Document; var Raw_Anchor_Button = doc.getElementsByTagName("a"); var Anchor_Button_List = Raw_Anchor_Button.OfType <mshtml.HTMLAnchorElement>().ToList(); if (Anchor_Button_List != null && Anchor_Button_List.Count() > 0) { Anchor_Button_List.ForEach(anchor => { string classname = anchor.getAttribute("className"); if (classname != null) { if (classname.Contains(Twoo_send_button)) { anchor.click(); } } }); Start_timer(Stages.navigate_to_unread_messages, Waits.wait_navigate_to_unread_messages); } }
public static List <mshtml.IHTMLElement> getElementsByClassName( this mshtml.HTMLDocument document, string className ) { var elements = document.getElementsByTagName("*"); var results = new List <mshtml.IHTMLElement>(); foreach (mshtml.IHTMLElement element in elements) { if (element.className != null) { var classNames = element.className.Split(' '); if (Array.IndexOf(classNames, className) > -1) { results.Add(element); } } } return(results); }
private void Try_to_send_message() { mshtml.HTMLDocument doc = (mshtml.HTMLDocument)Main_Web.Document; var Raw_Button_list = doc.getElementsByTagName("button"); var Button_List = Raw_Button_list.OfType <mshtml.HTMLButtonElement>().ToList(); if (Button_List != null && Button_List.Count() > 0) { Button_List.ForEach(btn => { string ident = btn.id; if (ident != null) { if (ident.Equals(Finya_send_button)) { btn.click(); } } }); Start_timer(Stages.navigate_to_unread_messages, Waits.wait_navigate_to_unread_messages); } }
// コピペ private mshtml.HTMLDivElement getDivElementsByClassName(mshtml.HTMLDocument document, string className) { try { if (document == null) { return(null); } var divs = document.getElementsByTagName("div"); foreach (mshtml.HTMLDivElement item in divs) { if (item.className == className) { return(item); } } return(null); } catch (Exception) { return(null); } }
//Sleep And Wait IE Complete public void SleepAndWaitComplete(SHDocVw.InternetExplorerMedium webApp, int tmOut = 100) { Sleep5(100); for (int i = 0; i <= 10; i++) { while (!(webApp.ReadyState == SHDocVw.tagREADYSTATE.READYSTATE_COMPLETE && !webApp.Busy)) { System.Windows.Forms.Application.DoEvents(); Sleep5(System.Convert.ToInt32((double)tmOut / 10)); i = 0; } while (!(((mshtml.HTMLDocument)webApp.Document).readyState.ToLower() == "complete")) { System.Windows.Forms.Application.DoEvents(); Sleep5(System.Convert.ToInt32((double)tmOut / 10)); i = 0; } try { mshtml.HTMLDocument Doc = (mshtml.HTMLDocument)webApp.Document; int length = System.Convert.ToInt32(Doc.frames.length); mshtml.FramesCollection frames = Doc.frames; for (int j = 0; j <= length - 1; j++) { mshtml.HTMLWindow2 frm = (mshtml.HTMLWindow2)(frames.item(j)); while (!(frm.document.readyState.ToLower() == "complete")) { System.Windows.Forms.Application.DoEvents(); Sleep5(1); } } } catch (Exception) { } } }
private void HandleDownloadActivity() { try { mshtml.HTMLDocument domDocument = (mshtml.HTMLDocument) this._webBrowser.Document; if (domDocument == null) { return; } if (_isLoading || _isLoaded) { return; } this._isLoading = true; if (domDocument.readyState == "complete") { DomDocumentCompleteHandler(domDocument); } else { DomEventHandler handler = null; handler = new DomEventHandler(delegate { if (domDocument.readyState == "complete") { domDocument.detachEvent("onreadystatechange", handler); DomDocumentCompleteHandler(domDocument); } }); domDocument.attachEvent("onreadystatechange", handler); } } catch (Exception ex) { AppLog.LogException(ex); } }
static public void GetRatings(mshtml.HTMLDocument doc, MovieDB db) { mshtml.IHTMLElementCollection item = doc.getElementsByTagName("div"); int lineIndex = 0; foreach (mshtml.IHTMLElement elem in item) { var score = elem.getAttribute("className"); if (score == "star_score" || score == "star_score ") { string text = elem.innerText; text = text.Replace("\r\n", ""); if (lineIndex == 0) { text = text.Replace("관람객 평점 ", ""); text = text.Replace("점", ","); db.audRating = text.Split(',')[0]; } else if (lineIndex == 1) { db.expRating = text; } else if (lineIndex == 2) { db.netRating = text; } lineIndex++; if (lineIndex >= 3) { break; } } } }
private void ProcessDocument(mshtml.HTMLDocument htmlDoc) { Boolean boolFilled = false; int intIndex = 0; string[] strData = new string[11]; if (!String.IsNullOrEmpty(dgEFMAK.SelectedRows[0].Cells[5].Value.ToString())) { strData[0] = DateTime.Parse(dgEFMAK.SelectedRows[0].Cells[5].Value.ToString()).ToString("dd/MM/yyyy");//tarik masuk } if (!String.IsNullOrEmpty(dgEFMAK.SelectedRows[0].Cells[6].Value.ToString())) { strData[1] = DateTime.Parse(dgEFMAK.SelectedRows[0].Cells[6].Value.ToString()).ToString("dd/MM/yyyy"); //tarik keluar } strData[2] = dgEFMAK.SelectedRows[0].Cells[0].Value.ToString(); //PREFIX strData[3] = dgEFMAK.SelectedRows[0].Cells[1].Value.ToString(); //REF strData[4] = dgEFMAK.SelectedRows[0].Cells[2].Value.ToString(); //NAME strData[5] = dgEFMAK.SelectedRows[0].Cells[3].Value.ToString(); //IC strData[6] = dgEFMAK.SelectedRows[0].Cells[4].Value.ToString(); //COUNTRY strData[7] = dgEFMAK.SelectedRows[0].Cells[7].Value.ToString(); //share strData[8] = dgEFMAK.SelectedRows[0].Cells[8].Value.ToString(); //b1 strData[9] = dgEFMAK.SelectedRows[0].Cells[9].Value.ToString(); //b2 strData[10] = dgEFMAK.SelectedRows[0].Cells[10].Value.ToString(); //b3 foreach (mshtml.HTMLInputElement inpElement1 in htmlDoc.getElementsByTagName("textarea")) { switch (inpElement1.name) { case "ctl00_ContentPlaceHolder2_GridView1_ctl02_Nama": inpElement1.value = strData[4].ToString().ToUpper(); break; } } foreach (mshtml.HTMLInputElement inpElement1 in htmlDoc.getElementsByTagName("input")) { switch (inpElement1.name) { case "ctl00$ContentPlaceHolder2$GridView1$ctl01$ddlEmpty_Negara": inpElement1.value = strData[6]; //MessageBox.Show("input1"); boolFilled = true; break; case "ctl00$ContentPlaceHolder2$GridView1$ctl01$txtEmpty_No_kp": inpElement1.value = strData[5]; break; case "ctl00$ContentPlaceHolder2$GridView1$ctl01$txtEmpty_No_rujukan": inpElement1.value = strData[3]; break; case "ctl00$ContentPlaceHolder2$GridView1$ctl01$ddlJ_Fail": inpElement1.value = strData[2]; break; case "ctl00$ContentPlaceHolder2$GridView1$ctl01$txtEmpty_tarikh_masuk": inpElement1.value = strData[0]; break; case "ctl00$ContentPlaceHolder2$GridView1$ctl01$txtEmpty_tarikh_keluar": inpElement1.value = strData[1]; break; case "ctl00$ContentPlaceHolder2$GridView1$ctl01$txtEmpty_bhgn_ahli": inpElement1.value = strData[7]; break; case "ctl00$ContentPlaceHolder2$GridView1$ctl01$txtEmpty_manfaat1": inpElement1.value = strData[8]; break; case "ctl00$ContentPlaceHolder2$GridView1$ctl01$txtEmpty_manfaat2": inpElement1.value = strData[9]; break; case "ctl00$ContentPlaceHolder2$GridView1$ctl01$txtEmpty_manfaat3": inpElement1.value = strData[10]; break; case "ctl00$ContentPlaceHolder2$GridView1$ctl01$Button1": inpElement1.click(); break; } } // ctl00$ContentPlaceHolder2$GridView1$ctl03$txtNama_Add for (intIndex = 3; intIndex < 20; intIndex++) { if (boolFilled == true) { break; } else { string strPrefix = "ctl00$ContentPlaceHolder2$GridView1$ctl" + intIndex.ToString("0#") + "$ddlJenis_Fail_Add"; string strRef = "ctl00$ContentPlaceHolder2$GridView1$ctl" + intIndex.ToString("0#") + "$txtNoRujukan2_Add"; string strName = "ctl00$ContentPlaceHolder2$GridView1$ctl" + intIndex.ToString("0#") + "$txtNama_Add"; string strIC = "ctl00$ContentPlaceHolder2$GridView1$ctl" + intIndex.ToString("0#") + "$txtNoPengenalan_Add"; string strCountry = "ctl00$ContentPlaceHolder2$GridView1$ctl" + intIndex.ToString("0#") + "$txtNegara_Add"; string strDateIn = "ctl00$ContentPlaceHolder2$GridView1$ctl" + intIndex.ToString("0#") + "$txtTkhMasuk_Add"; string strDateOut = "ctl00$ContentPlaceHolder2$GridView1$ctl" + intIndex.ToString("0#") + "$txtTkhKeluar_Add"; string strShare = "ctl00$ContentPlaceHolder2$GridView1$ctl" + intIndex.ToString("0#") + "$txtBhg_Ahli_Add"; string strB1 = "ctl00$ContentPlaceHolder2$GridView1$ctl" + intIndex.ToString("0#") + "$txtManfaat1_Add"; string strB2 = "ctl00$ContentPlaceHolder2$GridView1$ctl" + intIndex.ToString("0#") + "$txtManfaat2_Add"; string strB3 = "ctl00$ContentPlaceHolder2$GridView1$ctl" + intIndex.ToString("0#") + "$txtManfaat3_Add"; //string strNetDiv = "GridView1$ctl" + intIndex.ToString("0#") + "$txtdiv_bersih_Add"; foreach (mshtml.HTMLInputElement inpElement2 in htmlDoc.getElementsByTagName("input")) { if (inpElement2.name.ToString() == strRef) { inpElement2.value = strData[3].ToString().ToUpper(); boolFilled = true; } else if (inpElement2.name.ToString() == strIC) { inpElement2.value = strData[5]; boolFilled = true; } else if (inpElement2.name.ToString() == strDateIn) { inpElement2.value = strData[0]; boolFilled = true; } else if (inpElement2.name.ToString() == strDateOut) { inpElement2.value = strData[1]; boolFilled = true; } else if (inpElement2.name.ToString() == strShare) { inpElement2.value = strData[7]; boolFilled = true; } } foreach (mshtml.HTMLInputElement inpElement2 in htmlDoc.getElementsByTagName("textarea")) { if (inpElement2.name.ToString() == strName) { //inpElement2.value = strData[2]; inpElement2.value = strData[4].ToString().ToUpper(); boolFilled = true; } } foreach (mshtml.HTMLSelectElement selElement in htmlDoc.getElementsByTagName("select")) { if (selElement.name.ToString() == strCountry) { selElement.value = strData[6]; boolFilled = true; } else if (selElement.name.ToString() == strPrefix) { selElement.value = strData[2]; boolFilled = true; } else if (selElement.name.ToString() == strB1) { selElement.value = strData[8]; boolFilled = true; } else if (selElement.name.ToString() == strB2) { if (strData[9] == "1") { selElement.value = "2"; boolFilled = true; } else { selElement.value = ""; boolFilled = true; } } else if (selElement.name.ToString() == strB3) { if (strData[10] == "1") { selElement.value = "3"; boolFilled = true; } else { selElement.value = ""; boolFilled = true; } } } } } if (boolFilled == true) { intIndex = intIndex - 1; string strLnkAdd = "ctl00_ContentPlaceHolder2_GridView1_ctl" + intIndex.ToString("0#") + "_btnTambahFooter"; foreach (mshtml.HTMLAnchorElement ancElement in htmlDoc.getElementsByTagName("a")) { if (ancElement.id != null) { if (ancElement.id.ToString() == strLnkAdd) { ancElement.click(); } } } } }
/// <summary> /// Handler of the NavigateComplete2 event. /// </summary> public void NavigateComplete2Handler() { mshtml.IHTMLTxtRange theIHTMLTxtRange = null; htmlDocument = (mshtml.HTMLDocument)webBrowserUserControl.Document.DomDocument; htmlBody = (mshtml.HTMLBody)htmlDocument.body; // Determine if errors exist in the displayed Html. theIHTMLTxtRange = htmlBody.createTextRange(); if(theIHTMLTxtRange.text == null) { } else { containsErrors = theIHTMLTxtRange.findText(ERROR, theIHTMLTxtRange.text.Length, FIND_MATCH_CASE | FIND_MATCH_WHOLE_WORD); } // Determine if warnings exist in the displayed Html. theIHTMLTxtRange = htmlBody.createTextRange(); if(theIHTMLTxtRange.text == null) { } else { containsWarnings= theIHTMLTxtRange.findText(WARNING, theIHTMLTxtRange.text.Length, FIND_MATCH_CASE | FIND_MATCH_WHOLE_WORD); } findRemainingText = htmlBody.createTextRange(); ((mshtml.IHTMLSelectionObject)htmlDocument.selection).empty(); }
private void browser_LoadCompleted(object sender, System.Windows.Navigation.NavigationEventArgs e) { mDocument = (mshtml.HTMLDocument)MBW.browser.Document; DocLoaded = true; }
private void ProcessFormHK62014(mshtml.HTMLDocument htmlDoc) { //LEESH FEB 2012 boolFilled = false; foreach (mshtml.HTMLInputElement inpElement1 in htmlDoc.getElementsByTagName("textarea")) { switch (inpElement1.name) { case "GridView1$ctl01$txtEmpty_nama_syarikat": inpElement1.value = strData[3].ToString().ToUpper(); break; } } foreach (mshtml.HTMLInputElement inpElement1 in htmlDoc.getElementsByTagName("input")) { if (inpElement1.name == "txtfaedah") { inpElement1.value = strData[8]; inpElement1.blur(); break; } } foreach (mshtml.HTMLInputElement inpElement1 in htmlDoc.getElementsByTagName("input")) { switch (inpElement1.name) { case "GridView1$ctl01$txtEmpty_tkh_bayaran": inpElement1.value = strData[0]; boolFilled = true; break; case "GridView1$ctl01$txtEmpty_bg_thn_berakhir": inpElement1.value = strData[1]; break; case "GridView1$ctl01$txtEmpty_no_waran_siri": inpElement1.value = strData[2]; break; case "GridView1$ctl01$txtEmpty_div_kasar": inpElement1.value = strData[4]; break; case "GridView1$ctl01$txtEmpty_kadar_cukai": inpElement1.value = strData[5]; break; case "GridView1$ctl01$txtEmpty_cukai_dipotong": inpElement1.value = strData[6]; break; //case "GridView1$ctl01$txtEmpty_div_bersih": // inpElement1.value = strData[7]; // break; //case "GridView1$ctl01$txtEmpty_div_bersih2": // inpElement1.value = strData[8]; // break; //case "txtfaedah": // inpElement1.value = strData[8]; // inpElement1.blur(); // break; case "GridView1$ctl01$btnEmpty_Add": inpElement1.click(); break; } } for (intIndex = 3; ; intIndex++) { if (boolFilled == true) { break; } else { string strWaranNo = "GridView1$ctl" + intIndex.ToString("0#") + "$txtno_waran_siri_Add"; string strCompanyName = "GridView1$ctl" + intIndex.ToString("0#") + "$txtnama_syarikat_Add"; string strPaymentDate = "GridView1$ctl" + intIndex.ToString("0#") + "$txtTkh_bayaran_Add"; string strYearEnd = "GridView1$ctl" + intIndex.ToString("0#") + "$txtbg_thn_berakhir_Add"; string strGrossDiv = "GridView1$ctl" + intIndex.ToString("0#") + "$txtdiv_kasar_Add"; string strTaxRate = "GridView1$ctl" + intIndex.ToString("0#") + "$txtkadar_cukai_Add"; string strTaxDeduct = "GridView1$ctl" + intIndex.ToString("0#") + "$txtcukai_dipotong_Add"; //string strFaedah = "txtfaedah"; string strNetDiv = "GridView1$ctl" + intIndex.ToString("0#") + "$txtdiv_bersih_Add"; foreach (mshtml.HTMLInputElement inpElement2 in htmlDoc.getElementsByTagName("textarea")) { if (inpElement2.name.ToString() == strCompanyName) { inpElement2.value = strData[3].ToString().ToUpper(); } } foreach (mshtml.HTMLInputElement inpElement2 in htmlDoc.getElementsByTagName("input")) { if (inpElement2.name.ToString() == strWaranNo) { inpElement2.value = strData[2]; boolFilled = true; } else if (inpElement2.name.ToString() == strPaymentDate) { inpElement2.value = strData[0]; } else if (inpElement2.name.ToString() == strYearEnd) { inpElement2.value = strData[1]; } else if (inpElement2.name.ToString() == strGrossDiv) { inpElement2.value = strData[4]; } else if (inpElement2.name.ToString() == strTaxRate) { inpElement2.value = strData[5]; } else if (inpElement2.name.ToString() == strTaxDeduct) { inpElement2.value = strData[6]; } //else if (inpElement2.name.ToString() == strFaedah) //{ // inpElement2.value = strData[8]; //} else if (inpElement2.name.ToString() == strNetDiv) { inpElement2.value = strData[7]; } } } } if (boolFilled == true) { intIndex = intIndex - 1; string strLnkAdd = "GridView1_ctl" + intIndex.ToString("0#") + "_btnTambahFooter"; foreach (mshtml.HTMLAnchorElement ancElement in htmlDoc.getElementsByTagName("a")) { if (ancElement.id != null) { if (ancElement.id.ToString() == strLnkAdd) { ancElement.click(); } } } //LEESH END } }
private void webBrowser1_LoadCompleted(object sender, NavigationEventArgs e) { if (i == 0) { mshtml.HTMLDocument document = (mshtml.HTMLDocument)webBrowser1.Document; var elems = document.getElementsByName("commit"); foreach (mshtml.IHTMLElement button in elems) { mshtml.IHTMLElement k = button; k.click(); i = 1; } webBrowser1.Navigate("https://www.supremenewyork.com/checkout"); } else if (i == 1) { mshtml.HTMLDocument document2 = (mshtml.HTMLDocument)webBrowser1.Document; mshtml.IHTMLInputElement input = (mshtml.IHTMLInputElement)document2.getElementById("order_billing_name"); input.value = name_textbox.Text; input = (mshtml.IHTMLInputElement)document2.getElementById("order_email"); input.value = email_textbox.Text; input = (mshtml.IHTMLInputElement)document2.getElementById("order_tel"); input.value = tel_textbox.Text; input = (mshtml.IHTMLInputElement)document2.getElementById("bo"); input.value = add1_textbox.Text; input = (mshtml.IHTMLInputElement)document2.getElementById("oba3"); input.value = add2_textbox.Text; input = (mshtml.IHTMLInputElement)document2.getElementById("order_billing_zip"); input.value = zip_textbox.Text; input = (mshtml.IHTMLInputElement)document2.getElementById("order_billing_city"); input.value = city_textbox.Text; input = (mshtml.IHTMLInputElement)document2.getElementById("cnb"); input.value = number_textbox.Text; input = (mshtml.IHTMLInputElement)document2.getElementById("vval"); input.value = cvv_textbox.Text; mshtml.IHTMLSelectElement select = (mshtml.IHTMLSelectElement)document2.getElementById("order_billing_state"); select.value = state_combobox.Text; select = (mshtml.IHTMLSelectElement)document2.getElementById("credit_card_type"); if (type_combobox.Text == "Visa") { select.value = "visa"; } if (type_combobox.Text == "American Express") { select.value = "american_express"; } if (type_combobox.Text == "Master Card") { select.value = "master"; } select = (mshtml.IHTMLSelectElement)document2.getElementById("credit_card_month"); select.value = month_combobox.Text; select = (mshtml.IHTMLSelectElement)document2.getElementById("credit_card_year"); select.value = year_combobox.Text; var elems = document2.getElementsByName("order[terms]"); foreach (mshtml.IHTMLElement button in elems) { mshtml.IHTMLElement k = button; k.click(); } elems = document2.getElementsByName("commit"); foreach (mshtml.IHTMLElement button in elems) { mshtml.IHTMLElement k = button; k.click(); } i = 2; } }
private void myGetAnswer(object sender, EventArgs e) { mshtml.HTMLDocument document = (mshtml.HTMLDocument)WebBrowser1.Document; mshtml.IHTMLElement textArea = document.getElementById("myStudentInput1"); textBlock.Text = textArea.innerHTML; }
private void button8_Click_1(object sender, EventArgs e) { //webBrowser1.Refresh(); webBrowser1.Navigate("http://www.lockerz.com/myLocker"); objHtmlDoc = (mshtml.HTMLDocument)webBrowser1.Document.DomDocument; /*webBrowser1 is the WebBrowser Control showing your page*/ pageSource = objHtmlDoc.documentElement.innerHTML; textBoxWebBrowserStr.Text = pageSource; //pageSource = pageSource.Substring(int.Parse(textBoxBrowserSt.Text), int.Parse(textBoxBrowserEd.Text)); pageSource = pageSource.Substring(int.Parse(textBoxBrowserSt.Text), int.Parse(textBoxBrowserEd.Text)); //int x = pageSource.IndexOf("Featured Episodes"); labelBrowser.Text = pageSource; }
//private void tsbtnFill_Click(object sender, EventArgs e) //{ // SHDocVw.ShellWindows swTemp = new SHDocVw.ShellWindows(); // Boolean boolTargetFound = false; // Boolean boolTargetReady = false; // EFilingDALP dalP = new EFilingDALP(); // try // { // foreach (SHDocVw.InternetExplorer ieTemp in swTemp) // { // string strDocName = dalP.GetDocName(ieTemp.LocationURL.ToString().ToLower(), strYA); // if (strDocName.Length > 0) // { // boolTargetFound = true; // if (ieTemp.ReadyState.Equals(SHDocVw.tagREADYSTATE.READYSTATE_COMPLETE)) // { // boolTargetReady = true; // if (typeof(mshtml.HTMLDocumentClass).IsAssignableFrom(ieTemp.Document.GetType())) // { // mshtml.HTMLDocument htmlDoc = ieTemp.Document as mshtml.HTMLDocument; // ProcessDocument(htmlDoc); // } // } // } // } // if (boolTargetFound == false) // MessageBox.Show("No relevant document is found for E-Filling!", "TAXcom E-Filing", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); // else if (boolTargetFound == true && boolTargetReady == false) // MessageBox.Show("Document is not ready, please try again!", "TAXcom E-Filing", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); // } // catch (Exception ex) // { MessageBox.Show(ex.ToString()); } //} //private void toolStripButton1_Click(object sender, EventArgs e) //{ // GetData(); //} //private void dgEFMAK_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e) //{ // tsbtnFill_Click(sender, e); //} private void tsbtnFill_Click(object sender, EventArgs e) { SHDocVw.ShellWindows swTemp = new SHDocVw.ShellWindows(); Boolean boolTargetFound = false; Boolean boolTargetReady = false; EFilingDALP dalP = new EFilingDALP(); string[] strData = new string[17]; try { if (dgEFMAK.SelectedRows.Count > 0) { if (!String.IsNullOrEmpty(dgEFMAK.SelectedRows[0].Cells[5].Value.ToString())) { strData[0] = DateTime.Parse(dgEFMAK.SelectedRows[0].Cells[5].Value.ToString()).ToString("dd/MM/yyyy");//tarik masuk } else { strData[0] = ""; } if (!String.IsNullOrEmpty(dgEFMAK.SelectedRows[0].Cells[6].Value.ToString())) { strData[1] = DateTime.Parse(dgEFMAK.SelectedRows[0].Cells[6].Value.ToString()).ToString("dd/MM/yyyy");//tarik keluar } else { strData[1] = ""; } strData[2] = dgEFMAK.SelectedRows[0].Cells[0].Value.ToString(); //PREFIX strData[3] = dgEFMAK.SelectedRows[0].Cells[1].Value.ToString(); //REF strData[4] = dgEFMAK.SelectedRows[0].Cells[2].Value.ToString(); //NAME strData[5] = dgEFMAK.SelectedRows[0].Cells[3].Value.ToString(); //IC strData[6] = dgEFMAK.SelectedRows[0].Cells[4].Value.ToString(); //COUNTRY strData[7] = dgEFMAK.SelectedRows[0].Cells[7].Value.ToString(); //share strData[8] = dgEFMAK.SelectedRows[0].Cells[8].Value.ToString(); //b1 strData[9] = dgEFMAK.SelectedRows[0].Cells[9].Value.ToString(); //b2 strData[10] = dgEFMAK.SelectedRows[0].Cells[10].Value.ToString(); //b3 strData[11] = dgEFMAK.SelectedRows[0].Cells[11].Value.ToString(); //ADJUTED INCOME strData[12] = dgEFMAK.SelectedRows[0].Cells[12].Value.ToString(); //BALANCING CHARGE strData[13] = dgEFMAK.SelectedRows[0].Cells[13].Value.ToString(); //BALANCING ALLOWANCE strData[14] = dgEFMAK.SelectedRows[0].Cells[14].Value.ToString(); //schedule 4 strData[15] = dgEFMAK.SelectedRows[0].Cells[15].Value.ToString(); //export allowance strData[16] = dsData.Tables["P6_TAXP_PREPARTNER"].Rows[0].ItemArray[0].ToString(); } else { MessageBox.Show("No record found for E-Filling!", "TAXcom E-Filing", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } foreach (SHDocVw.InternetExplorer ieTemp in swTemp) { string strDocName = dalP.GetDocName(ieTemp.LocationURL.ToString().ToLower(), strYA); if (strDocName.Length > 0) { boolTargetFound = true; if (ieTemp.ReadyState.Equals(SHDocVw.tagREADYSTATE.READYSTATE_COMPLETE)) { boolTargetReady = true; if (typeof(mshtml.HTMLDocumentClass).IsAssignableFrom(ieTemp.Document.GetType())) { mshtml.HTMLDocument htmlDoc = ieTemp.Document as mshtml.HTMLDocument; EFilingProcessMaklumatAhliKongsi dalMAK = new EFilingProcessMaklumatAhliKongsi(strData, this.strYA); dalMAK.ProcessDocument(htmlDoc); } } } } if (boolTargetFound == false) { MessageBox.Show("No relevant document is found for E-Filling!", "TAXcom E-Filing", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else if (boolTargetFound == true && boolTargetReady == false) { MessageBox.Show("Document is not ready, please try again!", "TAXcom E-Filing", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void NicoWeb_LoadCompleted(object sender, NavigationEventArgs e) { this.Back.IsEnabled = this.NicoWeb.CanGoBack; this.Next.IsEnabled = this.NicoWeb.CanGoForward; this.webbrowserhtml = (mshtml.HTMLDocument)this.NicoWeb.Document; this.Title = this.webbrowserhtml.title; if (this.NicoManga.MangaIdSearch(this.NicoWeb.Source.ToString()) != null) { this.DL.IsEnabled = true; } else { this.DL.IsEnabled = false; } }
public HTMLEventHandler(mshtml.HTMLDocument htmlDocument) { this.htmlDocument = htmlDocument; }
//Get string public void vl1f2() { objHtmlDoc = (mshtml.HTMLDocument)webBrowser1.Document.DomDocument; /*webBrowser1 is the WebBrowser Control showing your page*/ pageSource = objHtmlDoc.documentElement.innerHTML; textBoxWebBrowserStr.Text = pageSource; pageSource = pageSource.Substring(int.Parse(textBoxBrowserSt.Text), int.Parse(textBoxBrowserEd.Text)); labelBrowser.Text = pageSource; if (first == true) { oldpageSource = pageSource; newpageSource = pageSource; } else { newpageSource = pageSource; } first = false; }
private void tsbtnFill_Click(object sender, EventArgs e) { SHDocVw.ShellWindows swTemp = new SHDocVw.ShellWindows(); Boolean boolTargetFound = false; Boolean boolTargetReady = false; EFilingDALB dalB = new EFilingDALB(); string[] strData = new string[10]; if (dgEFHK6.SelectedRows.Count > 0) { DateTime dtTemp1 = DateTime.Parse(dgEFHK6.SelectedRows[0].Cells[7].Value.ToString()); strData[0] = dgEFHK6.SelectedRows[0].Cells[0].Value.ToString(); strData[1] = dgEFHK6.SelectedRows[0].Cells[1].Value.ToString(); strData[2] = dgEFHK6.SelectedRows[0].Cells[2].Value.ToString(); strData[3] = dgEFHK6.SelectedRows[0].Cells[3].Value.ToString(); strData[4] = dgEFHK6.SelectedRows[0].Cells[4].Value.ToString(); strData[5] = dgEFHK6.SelectedRows[0].Cells[5].Value.ToString(); strData[6] = dgEFHK6.SelectedRows[0].Cells[6].Value.ToString(); strData[7] = dtTemp1.ToString("ddMMyyyy"); strData[8] = dgEFHK6.SelectedRows[0].Cells[8].Value.ToString(); strData[9] = dgEFHK6.SelectedRows[0].Cells[9].Value.ToString(); // strData[8] = dgEFHK6.SelectedRows[0].Cells[8].Value.ToString(); } else { MessageBox.Show("No record found for E-Filling!", "TAXcom E-Filing", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } try { foreach (SHDocVw.InternetExplorer ieTemp in swTemp) { string strDocName = dalB.GetDocName(ieTemp.LocationURL.ToString().ToLower(), strYA, strFormType); //testing //MessageBox.Show(strDocName.ToString()); //if (strDocName == "") // MessageBox.Show("strDocName is empty"); // strDocName = "BE2010Page3"; //endtesting if (strDocName.Length > 0) { boolTargetFound = true; if (ieTemp.ReadyState.Equals(SHDocVw.tagREADYSTATE.READYSTATE_COMPLETE)) { boolTargetReady = true; if (typeof(mshtml.HTMLDocumentClass).IsAssignableFrom(ieTemp.Document.GetType())) { mshtml.HTMLDocument htmlDoc = ieTemp.Document as mshtml.HTMLDocument; EFilingProcessHK6 dalProcessFormHK6 = new EFilingProcessHK6(strData, this.strYA); dalProcessFormHK6.ProcessDocument(htmlDoc); //ProcessDocument(htmlDoc); } } } } if (boolTargetFound == false) { MessageBox.Show("No relevant document is found for E-Filling!", "TAXcom E-Filing", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else if (boolTargetFound == true && boolTargetReady == false) { MessageBox.Show("Document is not ready, please try again!", "TAXcom E-Filing", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void mySetQuestion(object sender, EventArgs e) { mshtml.HTMLDocument document = (mshtml.HTMLDocument)WebBrowser1.Document; mshtml.IHTMLElement textArea = document.getElementById("myQuestion1"); textArea.innerHTML = "What is 1+1?"; }
public void AddMouseMoveEvnet() { mshtml.HTMLDocument doc; doc = (mshtml.HTMLDocument)_webBrowser.Document; mshtml.HTMLDocumentEvents2_Event iEvent; //Event in the mshtml Document through which mouse events can be raised. iEvent = (mshtml.HTMLDocumentEvents2_Event)doc; //iEvent.onclick += new mshtml.HTMLDocumentEvents2_onclickEventHandler(ClickEventHandler); //iEvent.onmousemove = if (_dwMouseMoveEventHandler != null) iEvent.onmousemove -= _dwMouseMoveEventHandler; _dwMouseMoveEventHandler = new mshtml.HTMLDocumentEvents2_onmousemoveEventHandler(MouseMoveEventHandler); iEvent.onmousemove += _dwMouseMoveEventHandler; }
/// <summary> /// Document complete method for the web browser /// Initiated by navigating to the about:blank page (EMPTY_PARAMETER HTML document) /// </summary> private void BrowserDocumentComplete(object sender, WebBrowserDocumentCompletedEventArgs e) { // get access to the HTMLDocument document = (mshtmlDocument)this.editorWebBrowser.Document.DomDocument; body = (mshtmlBody)document.body; // COM Interop Start // once browsing has completed there is the need to setup some options // need to ensure URLs are not modified when html is pasted IOleCommandTarget target = null; int hResult = HRESULT.S_OK; // try to obtain the command target for the web browser document try { // cast the document to a command target target = (IOleCommandTarget)document; // set the appropriate no url fixups on paste hResult = target.Exec(ref CommandGroup.CGID_MSHTML, (int)CommandId.IDM_NOFIXUPURLSONPASTE, (int)CommandOption.OLECMDEXECOPT_DONTPROMPTUSER, ref EMPTY_PARAMETER, ref EMPTY_PARAMETER); } // catch any exception and map back to the HRESULT catch (Exception ex) { hResult = Marshal.GetHRForException(ex); } // test the HRESULT for a valid operation if (hResult == HRESULT.S_OK) { // urls will not automatically be rebased rebaseUrlsNeeded = false; } else { //throw new HtmlEditorException(string.Format("Error executing NOFIXUPURLSONPASTE: Result {0}", hResult)); rebaseUrlsNeeded = true; } // COM Interop End // at this point the document and body has been loaded // so define the event handler for the context menu this.editorWebBrowser.Document.ContextMenuShowing += new HtmlElementEventHandler(DocumentContextMenu); this.editorWebBrowser.Document.AttachEventHandler("onselectionchange", DocumentSelectionChange); this.editorWebBrowser.Document.AttachEventHandler("onkeydown", DocumentKeyPress); // signalled complete codeNavigate = false; loading = false; // after navigation define the document Url string url = e.Url.ToString(); _bodyUrl = IsStringEqual(url, BLANK_HTML_PAGE) ? string.Empty : url; }
private mshtml.HTMLDocument CreateHTMLDoc(string htmlText) { mshtml.HTMLDocument cloneDoc = null; cloneDoc = new mshtml.HTMLDocument(); cloneDoc.open("text/html", "replace", null, null); cloneDoc.GetType().InvokeMember( "write", BindingFlags.InvokeMethod, null, cloneDoc, new object[] { htmlText }); return cloneDoc; }
private void adxieContextMenuCommandItem1_OnClick(object sender, object eventObject) { Type t = typeof(DownloadManager); int index = this.Bars.IndexOf(t.FullName); if (index >= 0) { AddinExpress.IE.ADXIEBarItem item = this.Bars[index]; if (item.BarObj == null) { object g = t.GUID.ToString("B"); object bShow = true; object dummy = null; IEApp.ShowBrowserBar(ref g, ref bShow, ref dummy); } else { DownloadManager dm = item.BarObj as DownloadManager; if (dm != null) { if (!dm.Visible) { object g = t.GUID.ToString("B"); object bShow = true; object dummy = null; IEApp.ShowBrowserBar(ref g, ref bShow, ref dummy); } } } if (item.BarObj is DownloadManager) { DownloadManager dm = item.BarObj as DownloadManager; if (dm.Visible) { if (dm.Links.Enabled) { if (eventObject is mshtml.IHTMLSelectionObject) { mshtml.IHTMLSelectionObject selection = eventObject as mshtml.IHTMLSelectionObject; mshtml.IHTMLTxtRange textRange = selection.createRange() as mshtml.IHTMLTxtRange; if (textRange != null && ((!String.IsNullOrEmpty(textRange.text)) && (!String.IsNullOrEmpty(textRange.htmlText)))) { bool linksFound = false; string text = textRange.text; string htmlText = textRange.htmlText; mshtml.HTMLDocument doc = new mshtml.HTMLDocument(); doc.open("text/html", "replace", null, null); doc.GetType().InvokeMember( "write", BindingFlags.InvokeMethod, null, doc, new object[] { htmlText }); if (doc.images.length > 0) { object attr; string src = String.Empty; foreach (mshtml.IHTMLElement element in doc.images) { src = String.Empty; attr = element.getAttribute("src", 0); if (attr is String) src = (string)attr; if (String.IsNullOrEmpty(src)) src = (string)element.getAttribute("href", 0); if (!String.IsNullOrEmpty(src)) { if (src.StartsWith("http:")) { string file = String.Empty; try { file = Path.GetFileName(src); } catch { } if (!String.IsNullOrEmpty(file)) { linksFound = true; dm.AddItem(file, src); } } } } } if (doc.links.length > 0) { string src = String.Empty; foreach (mshtml.IHTMLAnchorElement element in doc.links) { src = element.href; if (!String.IsNullOrEmpty(src)) { if (src.StartsWith("http:")) { string file = String.Empty; try { file = Path.GetFileName(src); } catch { } if (!String.IsNullOrEmpty(file)) { linksFound = true; dm.AddItem(file, src); } } } } } if (!linksFound) MessageBox.Show(this, "There are not valid links in the selection.", "Download Manager Example", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } else { string src = String.Empty; if (eventObject is mshtml.IHTMLAnchorElement) { mshtml.IHTMLAnchorElement element = eventObject as mshtml.IHTMLAnchorElement; src = element.href; } else if (eventObject is mshtml.IHTMLImgElement) { mshtml.IHTMLImgElement element = eventObject as mshtml.IHTMLImgElement; src = element.href; } if (!String.IsNullOrEmpty(src)) { if (src.StartsWith("http:")) { string file = String.Empty; try { file = Path.GetFileName(src); } catch { } if (!String.IsNullOrEmpty(file)) { dm.AddItem(file, src); return; } } MessageBox.Show(this, "The link is not valid.", "Download Manager Example", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } } } } } }
private void wb_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { // get access to the HTMLDocument var htmlDocument = wb.Document; if (!htmlDocument.IsNull()) { document = (mshtmlDocument)htmlDocument.DomDocument; _doc = (mshtmlIHTMLDocument2)htmlDocument.DomDocument; // at this point the document and body has been loaded // so define the event handler for the context menu htmlDocument.ContextMenuShowing += DocumentContextMenu; //htmlDocument.AttachEventHandler("onselectionchange", DocumentSelectionChange); htmlDocument.AttachEventHandler("onkeydown", DocumentKeyDown); htmlDocument.AttachEventHandler("onkeyup", DocumentKeyUp); } body = (mshtmlBody)document.body; // COM Interop Start // once browsing has completed there is the need to setup some options // need to ensure URLs are not modified when html is pasted int hResult; // try to obtain the command target for the web browser document try { // cast the document to a command target var target = (IOleCommandTarget)document; // set the appropriate no url fixups on paste hResult = target.Exec(ref CommandGroup.CGID_MSHTML, (int)CommandId.IDM_NOFIXUPURLSONPASTE, (int)CommandOption.OLECMDEXECOPT_DONTPROMPTUSER, ref EMPTY_PARAMETER, ref EMPTY_PARAMETER); } // catch any exception and map back to the HRESULT catch (Exception ex) { hResult = Marshal.GetHRForException(ex); } // test the HRESULT for a valid operation rebaseUrlsNeeded = hResult != HRESULT.S_OK; // COM Interop End // signalled complete codeNavigate = false; loading = false; // after navigation define the document Url string url = e.Url.ToString(); _bodyUrl = IsStringEqual(url, BLANK_HTML_PAGE) ? string.Empty : url; }
/// <summary> /// Handler of the NavigateComplete2 event. /// </summary> public void NavigateComplete2Handler() { mshtml.IHTMLTxtRange theIHTMLTxtRange = null; _HTMLDocument = (mshtml.HTMLDocument)_AxWebBrowser.Document; _HTMLBody = (mshtml.HTMLBody)_HTMLDocument.body; // Determine if errors exist in the displayed Html. theIHTMLTxtRange = _HTMLBody.createTextRange(); _ContainsErrors = theIHTMLTxtRange.findText(_ERROR, theIHTMLTxtRange.text.Length, _FIND_MATCH_CASE | _FIND_MATCH_WHOLE_WORD); // Determine if warnings exist in the displayed Html. theIHTMLTxtRange = _HTMLBody.createTextRange(); _ContainsWarnings= theIHTMLTxtRange.findText(_WARNING, theIHTMLTxtRange.text.Length, _FIND_MATCH_CASE | _FIND_MATCH_WHOLE_WORD); _FindRemainingText = _HTMLBody.createTextRange(); ((mshtml.IHTMLSelectionObject)_HTMLDocument.selection).empty(); }
private void ProcessDocument(mshtml.HTMLDocument htmlDoc) { Boolean boolFilled = false; int intIndex; DateTime dtTemp1 = DateTime.Parse(dgEFHK6.SelectedRows[0].Cells[7].Value.ToString()); //DateTime dtTemp2 = DateTime.Parse(dgEFHK6.SelectedRows[0].Cells[1].Value.ToString()); string[] strData = new string[9]; strData[0] = dgEFHK6.SelectedRows[0].Cells[0].Value.ToString(); strData[1] = dgEFHK6.SelectedRows[0].Cells[1].Value.ToString(); strData[2] = dgEFHK6.SelectedRows[0].Cells[2].Value.ToString(); strData[3] = dgEFHK6.SelectedRows[0].Cells[3].Value.ToString(); strData[4] = dgEFHK6.SelectedRows[0].Cells[4].Value.ToString(); strData[5] = dgEFHK6.SelectedRows[0].Cells[5].Value.ToString(); strData[6] = dgEFHK6.SelectedRows[0].Cells[6].Value.ToString(); strData[7] = dtTemp1.ToString("ddMMyyyy"); strData[8] = dgEFHK6.SelectedRows[0].Cells[8].Value.ToString(); strData[9] = dgEFHK6.SelectedRows[0].Cells[9].Value.ToString(); // strData[8] = dgEFHK6.SelectedRows[0].Cells[8].Value.ToString(); foreach (mshtml.HTMLInputElement inpElement1 in htmlDoc.getElementsByTagName("textarea")) { switch (inpElement1.name) { case "ctl00$ContentPlaceHolder1$GridView1$ctl01$txtEmpty_nama_pembayar": inpElement1.value = strData[4].ToString().ToUpper(); break; } } foreach (mshtml.HTMLInputElement inpElement1 in htmlDoc.getElementsByTagName("input")) { if (inpElement1.name == "txtfaedah") { inpElement1.value = strData[8]; inpElement1.blur(); break; } } foreach (mshtml.HTMLInputElement inpElement1 in htmlDoc.getElementsByTagName("input")) { switch (inpElement1.name) { case "ctl00$ContentPlaceHolder1$GridView1$ctl01$txtEmpty_pendapatan_kasar": inpElement1.value = strData[8]; boolFilled = true; break; case "ctl00$ContentPlaceHolder1$GridView1$ctl01$txtEmpty_cukai_dipotong": inpElement1.value = strData[1]; break; case "ctl00$ContentPlaceHolder1$GridView1$ctl01$txtEmpty_tkh_bayaran": inpElement1.value = strData[7]; break; case "ctl00$ContentPlaceHolder1$GridView1$ctl01$txtEmpty_no_resit": inpElement1.value = strData[6]; break; //case "GridView1$ctl01$txtEmpty_div_bersih": // inpElement1.value = strData[7]; // break; //case "GridView1$ctl01$txtEmpty_div_bersih2": // inpElement1.value = strData[8]; // break; //case "txtfaedah": // inpElement1.value = strData[8]; // inpElement1.blur(); // break; case "ctl00$ContentPlaceHolder1$GridView1$ctl01$btnEmpty_Add": inpElement1.click(); break; } } for (intIndex = 3; ; intIndex++) { if (boolFilled == true) { break; } else { string strWaranNo = "GridView1$ctl" + intIndex.ToString("0#") + "$txtno_waran_siri_Add"; string strCompanyName = "GridView1$ctl" + intIndex.ToString("0#") + "$txtnama_syarikat_Add"; string strPaymentDate = "GridView1$ctl" + intIndex.ToString("0#") + "$txtTkh_bayaran_Add"; string strYearEnd = "GridView1$ctl" + intIndex.ToString("0#") + "$txtbg_thn_berakhir_Add"; string strGrossDiv = "GridView1$ctl" + intIndex.ToString("0#") + "$txtdiv_kasar_Add"; string strTaxRate = "GridView1$ctl" + intIndex.ToString("0#") + "$txtkadar_cukai_Add"; string strTaxDeduct = "GridView1$ctl" + intIndex.ToString("0#") + "$txtcukai_dipotong_Add"; //string strFaedah = "txtfaedah"; //string strNetDiv = "GridView1$ctl" + intIndex.ToString("0#") + "$txtdiv_bersih_Add"; foreach (mshtml.HTMLInputElement inpElement2 in htmlDoc.getElementsByTagName("input")) { if (inpElement2.name.ToString() == strWaranNo) { inpElement2.value = strData[2]; boolFilled = true; } else if (inpElement2.name.ToString() == strCompanyName) { inpElement2.value = strData[3].ToString().ToUpper(); } else if (inpElement2.name.ToString() == strPaymentDate) { inpElement2.value = strData[0]; } else if (inpElement2.name.ToString() == strYearEnd) { inpElement2.value = strData[1]; } else if (inpElement2.name.ToString() == strGrossDiv) { inpElement2.value = strData[4]; } else if (inpElement2.name.ToString() == strTaxRate) { inpElement2.value = strData[5]; } else if (inpElement2.name.ToString() == strTaxDeduct) { inpElement2.value = strData[6]; } //else if (inpElement2.name.ToString() == strFaedah) //{ // inpElement2.value = strData[8]; //} //else if (inpElement2.name.ToString() == strNetDiv) //{ // inpElement2.value = strData[7]; //} } } } if (boolFilled == true) { intIndex = intIndex - 1; string strLnkAdd = "GridView1_ctl" + intIndex.ToString("0#") + "_btnTambahFooter"; foreach (mshtml.HTMLAnchorElement ancElement in htmlDoc.getElementsByTagName("a")) { if (ancElement.id != null) { if (ancElement.id.ToString() == strLnkAdd) { ancElement.click(); } } } } }
private void axWebBrowser1_DocumentComplete(object sender, AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEvent e) { mshtml.HTMLDocument x = (mshtml.HTMLDocument) this.axWebBrowser1.Document; x.body.innerHTML = "<body style='background-color:gray;'>これは実験</body>"; }
private void WebDescriptionView_DocumentComplete(object sender, AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEvent e) { Cursor.Current = Cursors.Default; /* // update the URL displayed in the address bar String s = e.uRL.ToString(); // update the list of visited URLs int i = urlsVisited.IndexOf(s); if (i >= 0) currentUrlIndex = i; else currentUrlIndex = urlsVisited.Add(s); */ // get access to the HTMLDocument this.document = (HtmlDocument)this.WebDescriptionView.Document; this.document_body = (HtmlBody)document.body; // at this point the document and body has been loaded // so define the event handler as the same class ((mshtml.DispHTMLDocument)document).oncontextmenu = this; ((mshtml.DispHTMLDocument)document).onkeypress = this; ((mshtml.DispHTMLDocument)document).onkeydown = this; ((mshtml.DispHTMLDocument)document).onkeyup = this; /* // Update the context sensitive menu for the browser this.CM_Back.Enabled = this.can_navigate_back; this.CM_Forward.Enabled = this.can_navigate_forward; */ //this.CM_FindAgain.Enabled = (((MainForm)this.ParentForm).search_string != ""); // the search options value '6' maps to: 'match case' & 'match whole words'. this.FindReset(); this._contains_errors = this.find_range.findText ("Error:", this.find_range.text.Length, 6); this.FindReset(); this._contains_warnings = this.find_range.findText ("Warning:", this.find_range.text.Length, 6); this.FindReset(); // Update the controls of the mainform (toolbar, menubar, title bar) ((MainForm)this.ParentForm).UpdateUIControls (); }
private void Links_DragDrop(object sender, DragEventArgs e) { string html; bool linksFound = false; int startHtml = -1, endHtml = -1; IDataObject data = e.Data; if (data.GetDataPresent("HTML Format")) { html = (string)data.GetData("HTML Format"); int index = html.IndexOf("StartHTML:"); if (index > 0) { startHtml = Convert.ToInt32(html.Substring(index + 10, 9)); index = html.IndexOf("EndHTML:"); if (index > 0) { endHtml = Convert.ToInt32(html.Substring(index + 8, 9)); } } if (startHtml != -1 && endHtml != -1) { html = html.Substring(startHtml, endHtml - startHtml); index = html.IndexOf("<HTML>"); if (index > 0) { html = html.Remove(0, index); startHtml = html.IndexOf("<HEAD>"); if (startHtml > 0) { endHtml = html.IndexOf("</HEAD>"); if (endHtml > 0) { html = html.Remove(startHtml, (endHtml - startHtml) + 7); } } } mshtml.HTMLDocument doc = new mshtml.HTMLDocument(); doc.open("text/html", "replace", null, null); doc.GetType().InvokeMember( "write", BindingFlags.InvokeMethod, null, doc, new object[] { html } ); if (doc.images.length > 0) { object attr; string src = String.Empty; foreach (mshtml.IHTMLElement element in doc.images) { src = String.Empty; attr = element.getAttribute("src", 0); if (attr is String) src = (string)attr; if (String.IsNullOrEmpty(src)) src = (string)element.getAttribute("href", 0); if (!String.IsNullOrEmpty(src)) { if (src.StartsWith("http:")) { string file = String.Empty; try { file = Path.GetFileName(src); } catch { } if (!String.IsNullOrEmpty(file)) { linksFound = true; AddItem(file, src); } } } } } if (doc.links.length > 0) { string src = String.Empty; foreach (mshtml.IHTMLAnchorElement element in doc.links) { src = element.href; if (!String.IsNullOrEmpty(src)) { if (src.StartsWith("http:")) { string file = String.Empty; try { file = Path.GetFileName(src); } catch { } if (!String.IsNullOrEmpty(file)) { linksFound = true; AddItem(file, src); } } } } } if (!linksFound) MessageBox.Show(this, "There are not valid links in the selection.", "Download Manager Example", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } }
private void IncapsulaResolver() { string sitekey = string.Empty; string url = string.Empty; var captchaResolver = new Captcha(); retryCap: try { for (int i = 0; i < 5; i++) { AuthClient.Navigate(this.TargetUri.Scheme + Uri.SchemeDelimiter + this.TargetUri.Host.ToString()); Sleep(300); } AuthClient.Navigate(this.TargetUri.Scheme + Uri.SchemeDelimiter + this.TargetUri.Host.ToString()); Sleep(5000); if (!AuthClient.DocumentText.Contains("Request unsuccessful")) { return; } mshtml.HTMLDocument doc = (mshtml.HTMLDocument)AuthClient.Document.DomDocument; object index = 0; mshtml.IHTMLWindow2 frame2 = (mshtml.IHTMLWindow2)doc.frames.item(ref index); doc = (mshtml.HTMLDocument)frame2.document; Regex reg = new Regex("data-sitekey=\"(.[^\"]+)\""); MatchCollection result = reg.Matches(doc.documentElement.innerHTML); foreach (Match mm in result) { sitekey = mm.Groups[1].ToString(); } Regex reg2 = new Regex("\"POST\", \"(.+)\","); MatchCollection result2 = reg2.Matches(doc.documentElement.innerHTML); foreach (Match mm in result2) { url = mm.Groups[1].ToString(); } NoSlot: string capId = captchaResolver.reCaptcha(Config.captchaKey, sitekey, AuthClient.Url.ToString()); if (capId.Equals("ERROR_KEY_DOES_NOT_EXIST") || capId.Equals("ERROR_ZERO_BALANCE")) { return; } else if (capId.Equals("ERROR_NO_SLOT_AVAILABLE")) { System.Threading.Thread.Sleep(10000); goto NoSlot; } else if (capId.Contains("ERROR")) { goto retryCap; } System.Threading.Thread.Sleep(15000); string answer = captchaResolver.resCaptcha(Config.captchaKey, capId); if (answer.Equals("ERROR_CAPTCHA_UNSOLVABLE")) { goto retryCap; } AuthClient.Document.InvokeScript("eval", new object[] { "var xhr;" }); AuthClient.Document.InvokeScript("eval", new object[] { "xhr = (window.XMLHttpRequest) ? new XMLHttpRequest : new ActiveXObject(\"Microsoft.XMLHTTP\");" }); AuthClient.Document.InvokeScript("eval", new object[] { "var msg = \"g-recaptcha-response=" + answer + "\";" }); AuthClient.Document.InvokeScript("eval", new object[] { "xhr.open(\"POST\", \"" + url + "\", true);" }); AuthClient.Document.InvokeScript("eval", new object[] { "xhr.setRequestHeader(\"Content-Type\", \"application/x-www-form-urlencoded\");" }); AuthClient.Document.InvokeScript("eval", new object[] { "xhr.onreadystatechange = function(){ if (xhr.readyState == 4) { window.parent.location.reload(true); }};" }); AuthClient.Document.InvokeScript("eval", new object[] { "xhr.send(msg);" }); Sleep(5000); if (AuthClient.DocumentText.Contains("Request unsuccessful")) { goto retryCap; } } catch (Exception ex) { Console.WriteLine(ex); goto retryCap; } }
// private void axWebBrowser2_DownloadComplete(object sender, System.EventArgs e) // { // //iEvent.onclick += new mshtml.HTMLInputTextElementEvents2_onclickEventHandler(openwebshare); // //System.Windows.Forms.MessageBox.Show("event of the download is completed"); // // //iEvent.oncontextmenu+=new mshtml.HTMLDocumentEvents2_oncontextmenuEventHandler(ContextMenuEventHandler); // } private void axWebBrowser1_DocumentComplete(object sender, AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEvent e) { try { doc = (mshtml.HTMLDocument)axWebBrowser2.Document; mshtml.HTMLDocumentEvents2_Event iEvent; iEvent = (mshtml.HTMLDocumentEvents2_Event) doc; string str=this.axWebBrowser2.LocationURL; if(str.IndexOf("slideshow.php") > 0) // these are dependent on file(.php) names of manage Content. { // if(!(ClientUI.getInstance().tabControlWebContent.SelectedTab.Title == ClientUI.getInstance().tabPageWebPresentations.Title) ) // ClientUI.getInstance().tabControlWebContent.SelectedTab = ClientUI.getInstance().tabPageWebPresentations; } else if(str.IndexOf("premquestions.php") > 0) { // if(!(ClientUI.getInstance().tabControlWebContent.SelectedTab.Title == ClientUI.getInstance().tabPageWebContentPolls.Title)) // ClientUI.getInstance().tabControlWebContent.SelectedTab = ClientUI.getInstance().tabPageWebContentPolls; } else if(str.IndexOf("dmquestions.php") > 0) { // if(!(ClientUI.getInstance().tabControlWebContent.SelectedTab.Title == ClientUI.getInstance().tabPageWebContentPolls.Title)) // ClientUI.getInstance().tabControlWebContent.SelectedTab = ClientUI.getInstance().tabPageWebContentPolls; } else if(str.IndexOf("webshare.php") > 0) { // if(!(ClientUI.getInstance().tabControlWebContent.SelectedTab.Title == ClientUI.getInstance().tabPageWebContentBookmarks.Title) ) // ClientUI.getInstance().tabControlWebContent.SelectedTab = ClientUI.getInstance().tabPageWebContentBookmarks; } else if(str.IndexOf("uploads.php") > 0) { // if(!(ClientUI.getInstance().tabControlWebContent.SelectedTab.Title == ClientUI.getInstance().tabPageWebFiles.Title) ) // ClientUI.getInstance().tabControlWebContent.SelectedTab = ClientUI.getInstance().tabPageWebFiles; } else if(str.IndexOf("postmquestions.php") > 0) { // if(!(ClientUI.getInstance().tabControlWebContent.SelectedTab.Title == ClientUI.getInstance().tabPageWebEvaluation.Title) ) // ClientUI.getInstance().tabControlWebContent.SelectedTab = ClientUI.getInstance().tabPageWebEvaluation; } // doc = (mshtml.HTMLDocument)axWebBrowser1.Document; // mshtml.HTMLDocumentEvents2_Event iEvent; // iEvent = (mshtml.HTMLDocumentEvents2_Event) doc; // iEvent.oncontextmenu+=new mshtml.HTMLDocumentEvents2_oncontextmenuEventHandler(ContextMenuEventHandler); } catch(Exception exp) { WebMeeting.Client.ClientUI.getInstance().ShowExceptionMessage("ManageContents ===>MAnageContentBookmark.cs line==> 293",exp,null,false); } }