/// <summary> /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// </summary> /// <param name="disposing"> True if disposing and false if otherwise. </param> protected override void Dispose(bool disposing) { if (!disposing) { return; } try { if (_browser == null || !AutoClose) { return; } WaitForComplete(); // We cannot allow the browser to close within a second. // I assume that add-on(s) need time to start before closing the browser. var timeout = TimeSpan.FromMilliseconds(1000); var watch = Stopwatch.StartNew(); while (watch.Elapsed <= timeout) { Thread.Sleep(50); } _browser.Quit(); } catch { _browser = null; } }
public IETabWindow( SHDocVw.InternetExplorer tab ) : base(new IntPtr(tab.HWND)) { this.title = tab.LocationName + " - Internet Explorer"; this.ie = tab; Console.Write(this.handle); }
/// <summary> /// IE起動を待つ /// </summary> /// <param name="ie"></param> /// <param name="millisecond"></param> private void IEWait(SHDocVw.InternetExplorer ie, int millisecond = 2000) { while (ie.Busy == true || ie.ReadyState != SHDocVw.tagREADYSTATE.READYSTATE_COMPLETE) { Thread.Sleep(100); } Thread.Sleep(millisecond); }
/// <summary> /// Disconnects from the current browser and finds the new instance. /// </summary> private string ReinitializeBrowser() { Application.Dispose(); _browser = GetBrowserToAttachTo() ?? CreateInternetExplorerClass(); Application = Application.Attach(new IntPtr(_browser.HWND), false); _zoneId = NativeMethods.GetZoneId(_browser.LocationURL); return(_browser.LocationURL); }
public ExplorerWindowRepresentor(SHDocVw.InternetExplorer ie, bool bind = false) { IE = ie; if (bind) { Bind(); } }
public HTMLEvents(IGenerator builder, object i, SHDocVw.InternetExplorer browser) { ie = browser; document = (IHTMLDocument2)i; _builder = builder; ConnectToHtmlEvents(); //_builder.OnAfterWriteCommand+=new OnAfterGenerateCommandEventHandler(processCommand); //_uiHandler = uiHandler; //_builder.OnFinishedWritingBatchOfCommands+=new EventHandler(updateUI); }
public void Initialize() { try { WindowProc.KillProcess("iexplore"); ie = new SHDocVw.InternetExplorer(); } catch (Exception ex) { SharpLog.Error("WebProcInit", ex.ToString()); } }
/// <summary> /// http://devdistrict.com/codedetails.aspx?A=416 /// </summary> public static void OpeningInternetExplorer() { //Create a reference to IE SHDocVw.InternetExplorer ie = new SHDocVw.InternetExplorer(); //Make it visible so we can see it ie.Visible = true; object o = null; //Navigate to a web page ie.Navigate("http://devdistrict.com", ref o, ref o, ref o, ref o); }
public void Run() { Object o = null; String s; try { // start the browser m_IExplorer = new SHDocVw.InternetExplorer(); } catch (Exception e) { Console.WriteLine("Exception when creating IE object {0}", e); return; } // Set the events SetAllEvents(); try { // go to home page m_WebBrowser = (IWebBrowserApp)m_IExplorer; m_WebBrowser.Visible = true; m_WebBrowser.GoHome(); // start navigating to different urls Console.Write("Enter URL (or enter to quit): "); s = Console.ReadLine(); while (s != "" && m_IExplorer != null && m_WebBrowser != null) { m_WebBrowser.Navigate(s, ref o, ref o, ref o, ref o); Console.Write("Enter URL (or enter to quit): "); s = Console.ReadLine(); } m_WebBrowser.Quit(); } catch (Exception sE) { if (m_IExplorer == null && m_WebBrowser == null) { Console.WriteLine("IE has gone away"); } else { Console.WriteLine("Exception happens {0}", sE); } } }
private static bool doesIEWindowExist(int hwnd) { SHDocVw.ShellWindows sws = new SHDocVw.ShellWindows(); for (int i = 0; i < sws.Count; i++) { SHDocVw.InternetExplorer ie = (SHDocVw.InternetExplorer)sws.Item(i); if (ie.HWND == hwnd) { return(true); } } return(false); }
/// <summary> /// Provides the site's IUnknown pointer to the object. /// </summary> /// <param name="pUnkSite"> /// An interface pointer to the site managing this object. If NULL, the /// object should call IUnknown::Release to release the existing site. /// </param> public void SetSite(object pUnkSite) { // Clear out old references to the band object site if (!(pUnkSite is SHDocVw.InternetExplorer)) { if (BandObjectSite != null) { Marshal.ReleaseComObject(BandObjectSite); BandObjectSite = null; } return; } try { // Set the band object site to be a reference to the current // site passed to this function BandObjectSite = (SHDocVw.InternetExplorer)pUnkSite; // Grab an IServiceProvider instance from the band object site ProIeDev.BandObjectDemo.Interop.Interfaces.IServiceProvider serviceProvider = (ProIeDev.BandObjectDemo.Interop.Interfaces.IServiceProvider) BandObjectSite; // Create variables to be referenced in a call to QueryService object pUnknown = null; Guid guid = new Guid(IID.IID_IWebBrowserApp); Guid riid = new Guid(IID.IID_IUnknown); // Query the service provider to the IWebBrowser instnace serviceProvider.QueryService(ref guid, ref riid, out pUnknown); // Cast the returned site to an IWebBrowser instance and save // it to an instance variable WebBrowser = (SHDocVw.WebBrowserClass)Marshal.CreateWrapperOfType( pUnknown as IWebBrowser, typeof(SHDocVw.WebBrowserClass)); // Create variables to be used in a call to the ShowBrowserBar // function on the new IWebBrowser instance object pvaClsid = (object)ClassId; object pvarSize = null; object pvarShowTrue = (object)true; // Call the ShowBrowserBar function on the retrieved IWebBrowser // instance to display the current band object WebBrowser.ShowBrowserBar(ref pvaClsid, ref pvarShowTrue, ref pvarSize); } catch (Exception) { } }
/// <summary> /// Run/evaluate JavaScript code in the DOM context. /// </summary> /// <param name="browserWindow">The browser window.</param> /// <param name="code">The JavaScript code</param> public static void RunScript(BrowserWindow browserWindow, string code) { SHDocVw.InternetExplorer internetExplorer = null; ShellWindows shellWindows = new ShellWindows(); foreach (SHDocVw.InternetExplorer shellWindow in shellWindows) { if (shellWindow.HWND == browserWindow.WindowHandle.ToInt32()) { internetExplorer = shellWindow; break; } } internetExplorer.Document.parentWindow.execScript(code); }
public static void Wait(this SHDocVw.InternetExplorer ie, int millisecond = 0) { int count = 0; while (ie.Busy == true) //while (ie.Busy == true || ie.ReadyState != SHDocVw.tagREADYSTATE.READYSTATE_COMPLETE) { System.Threading.Thread.Sleep(100); count++; if (count == 300) { return; } } }
/// <summary> /// http://weblogs.asp.net/stevencohn/archive/2004/01/23/62117.aspx Automating IE Remotely Using C# /// </summary> public static void AutomatingIERemotely() { string filename; SHDocVw.InternetExplorer browser = null; SHDocVw.ShellWindows shellWindows = new SHDocVw.ShellWindowsClass(); foreach (SHDocVw.InternetExplorer ie in shellWindows) { filename = Path.GetFileNameWithoutExtension(ie.FullName).ToLower(); if (filename.Equals("iexplore")) { browser = ie; break; } } }
public static object visit(object ast, TextWriter w, string[] args, MessageWriter msg) { int nf = 0; string oname = null; foreach (string s in args) { if (s.StartsWith("-file=")) { oname = s.Substring(6); nf++; } } if (oname == null) { oname = Path.GetTempFileName(); File.Delete(oname); oname = Path.ChangeExtension(oname, ".htm"); } try { TextWriter wr = new StreamWriter(oname); if (oname.EndsWith(".htm") || oname.EndsWith(".html")) { Debug.DumpAllHTML(ast, wr); } else { Debug.DumpAll(ast, wr); } wr.Close(); } catch (Exception e) { msg.Error("can't write \"{0}\" ({1})", oname, e.ToString()); return(ast); } if (nf == 0) { try { object o = null; IWebBrowserApp ie = new SHDocVw.InternetExplorer(); ie.Visible = true; ie.Navigate(oname, ref o, ref o, ref o, ref o); } catch (Exception e) { msg.Error("can't launch Internet Explorer ({0})", e.ToString()); } } return(ast); }
public Browser(IBrowserEvents sink) { InternetExplorer explorer = new SHDocVw.InternetExplorer(); if (explorer == null || sink == null) { Debug.Assert(false); return; } AttachSink(explorer, sink); // go to home page m_browser = (IWebBrowserApp)explorer; m_browser.Visible = true; m_browser.GoHome(); }
internal void OpenLinkInNewWindow(string url) { switch (type) { case BrowserType.IExplore: { NewWindowWasOpened = true; var iExplorer = new SHDocVw.InternetExplorer { ToolBar = 0, StatusBar = false, MenuBar = false, Width = width, Height = height, Visible = true }; iExplorer.Navigate(url); NewWindowHWND = new IntPtr(iExplorer.HWND); BringWindowToTop(NewWindowHWND); } break; case BrowserType.Chrome: case BrowserType.Firefox: { NewWindowWasOpened = true; var args = string.Format(GetNewWindowOption(), url); StartBrowser(args); ResizeWindow(); } break; default: { var process = Process.Start(url); if (process != null) { NewWindowHWND = process.MainWindowHandle; } } break; } }
/// <summary> /// If connection to existing Innovator is required then find the first IE window with the /// specified URL. Otherwise, create a new IE window. /// </summary> /// <returns></returns> private static InternetExplorer getIEHandle() { if (!NewIE) { SHDocVw.ShellWindows sws = new SHDocVw.ShellWindows(); for (int i = 0; i < sws.Count; i++) { SHDocVw.InternetExplorer ie = (SHDocVw.InternetExplorer)sws.Item(i); int h = ie.HWND; if (ie.LocationURL.Length >= InnovatorURL.Length && InnovatorURL.ToLower().Equals(ie.LocationURL.ToLower().Substring(0, InnovatorURL.Length))) { return(ie); } } return(null); } else { return((InternetExplorer)(new InternetExplorerClass())); } }
/// <summary> /// Disconnects from the current browser and finds the new instance. /// </summary> private string ReinitializeBrowser() { Application.Dispose(); _browser = GetBrowserToAttachTo() ?? CreateInternetExplorerClass(); Application = Application.Attach(new IntPtr(_browser.HWND), false); _zoneId = NativeMethods.GetZoneId(_browser.LocationURL); return _browser.LocationURL; }
public void OpenUrl(String url) { //object o = null; ie = new SHDocVw.InternetExplorerClass(); if (this.allowNewWnd) { ie.Resizable = false; ie.FullScreen = false; } else { ie.FullScreen = true; ie.Resizable = false; } ie.AddressBar = false; ie.MenuBar = false; ie.ToolBar = 0; ie.Visible = true; SendMessage(new IntPtr(ie.HWND), WM_SYSCOMMAND, SC_MAXIMIZE, 0); ie.Navigate2(url); ie.BeforeNavigate2 += new SHDocVw.DWebBrowserEvents2_BeforeNavigate2EventHandler(beforeNavHandler); ie.NewWindow2 += new SHDocVw.DWebBrowserEvents2_NewWindow2EventHandler(wbEvents_NewWindow2); ie.NewWindow3 += new SHDocVw.DWebBrowserEvents2_NewWindow3EventHandler(wbEvents_NewWindow3); ie.NewProcess += new SHDocVw.DWebBrowserEvents2_NewProcessEventHandler(wbEvents_NewProcess); ie.DocumentComplete += new SHDocVw.DWebBrowserEvents2_DocumentCompleteEventHandler(wbEvents_DocumentComplete); ie.WindowClosing += new SHDocVw.DWebBrowserEvents2_WindowClosingEventHandler(wbEvents_WindowClosing); }
/// <summary> /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// </summary> /// <param name="disposing"> True if disposing and false if otherwise. </param> protected override void Dispose(bool disposing) { if (!disposing) { return; } try { if ((_browser == null) || !AutoClose) { return; } WaitForComplete(); // We cannot allow the browser to close within a second. // I assume that add-on(s) need time to start before closing the browser. var timeout = TimeSpan.FromMilliseconds(1000); var watch = Stopwatch.StartNew(); while (watch.Elapsed <= timeout) { Thread.Sleep(50); } _browser.Quit(); } catch { _browser = null; } }
private void attachToBrowser(int waitTime, string titleContents, int index) { string windowTitleLowerCase = setUpPDFExtentions(titleContents).ToLower(); HTMLDocument ourDoc = null; IntPtr winHndle = IntPtr.Zero; SHDocVw.InternetExplorer oldBrowser = currentIEBrowser; currentIEBrowser = null; _attachedToModalDialog = false; int indexCount = 0; DateTime timeout = DateTime.Now.AddSeconds(waitTime); while (DateTime.Now < timeout) { //we must reset indexCount every iteration of this loop indexCount = 0; ShellWindows m_IEFoundBrowsers = new ShellWindowsClass(); foreach (SHDocVw.InternetExplorer browser in m_IEFoundBrowsers) { try { if (browser.Name.Equals(ieBrowserName)) { // Check if browser is the one we are looking for if (browserTitleIsMatch(browser, windowTitleLowerCase)) { if (indexCount == index) { currentIEBrowser = browser; curWindowHandle = new IntPtr(currentIEBrowser.HWND); if (browser.Type.Contains("PDF")) { return; // We are done here } break; } else { indexCount++; } } } } catch (COMException) { // A window was manually closed while iterating through ShellWindows continue; } } //if currentIEBrowser is null, then we havent found any browser windows...so check dialogs if (currentIEBrowser != null) ourDoc = (mshtml.HTMLDocument)currentIEBrowser.Document; else attachToModalDialog(titleContents, index, indexCount, ref ourDoc); //if the doc isn't null but the browser is, we have found a dialog, reassign the browser to the previous one if (ourDoc != null) { if (currentIEBrowser == null) { _attachedToModalDialog = true; currentIEBrowser = oldBrowser; } break; } } if (ourDoc == null) { if (indexCount == 0) throw new WindowNotFoundException(titleContents); string message; if (indexCount == 1) message = "There is only 1 window"; else message = "There are only " + indexCount + " windows"; throw new IndexOutOfRangeException(message + " with " + titleContents + " in the title."); } setDocument(ourDoc); bringCurrentBrowserWindowToTop(); }
public void OpenBrowser() { bool done = false; while (!done) { try { currentIEBrowser = (InternetExplorerClass)Activator.CreateInstance(typeof(InternetExplorerClass)); currentIEBrowser.Visible = true; curWindowHandle = new IntPtr(currentIEBrowser.HWND); done = true; } catch { } } navigateTo("about:Blank"); setDocument(currentIEBrowser.Document as HTMLDocument); bringCurrentBrowserWindowToTop(); }
private void init_ie() { ie = new SHDocVw.InternetExplorer(); }
static void Main(string[] args) { int counter = 0; string found = ""; // Set up your credentials (https://apps.twitter.com) Auth.SetUserCredentials("", "", "", ""); //Throw in twitter keys here var tweets = Timeline.GetUserTimeline("dumpmon"); SHDocVw.InternetExplorer IE = new SHDocVw.InternetExplorer(); IE.Navigate("google.com"); List <string> searchTerms = new List <String>(); var tweetArray = tweets.ToArray(); while (IE.ReadyState != SHDocVw.tagREADYSTATE.READYSTATE_COMPLETE) { Console.Write("Setting up environment"); System.Threading.Thread.Sleep(500); Console.Clear(); Console.Write("Setting up environment."); System.Threading.Thread.Sleep(500); Console.Clear(); Console.Write("Setting up environment.."); System.Threading.Thread.Sleep(500); Console.Clear(); Console.Write("Setting up environment..."); System.Threading.Thread.Sleep(500); Console.Clear(); } while (!searchTerms.Contains("done")) { Console.WriteLine("Enter a term to search for or type '<>' to start the search. Type '!!' to exit"); string text = Console.ReadLine(); if (text != "<>" && text != "!!") { searchTerms.Add(text); } else if (text == "!!") { Environment.Exit(0); } else { searchTerms.Add("done"); } } searchTerms.Remove("done"); for (int i = 0; i < tweets.Count(); i++) { string url = tweetArray[i].ToString(); url = url.Remove(23, url.Length - 23); //Trim tweet to just URL IE.Navigate(url); while (IE.ReadyState != SHDocVw.tagREADYSTATE.READYSTATE_COMPLETE) { } //Gather HTML for checking mshtml.IHTMLDocument2 doc = IE.Document as mshtml.IHTMLDocument2; for (int j = 0; j < searchTerms.Count; j++) { if (doc.body.innerText.Contains(searchTerms[j])) { Console.WriteLine(url + " DETAILS FOUND!"); Console.WriteLine("DETAILS FOUND!"); found = found + (url + "\n"); counter++; } else { Console.WriteLine(url + " Checked against check data #" + (j + 1) + "------> 0 hits"); } } } Console.WriteLine("\n\n"); Console.Write(counter + " hit/s "); Console.WriteLine(found); if (found != "") { string strPath = Environment.GetFolderPath(System.Environment.SpecialFolder.DesktopDirectory); string strDate = DateTime.Today.Date.ToString("yyyy-MM-dd"); System.IO.File.WriteAllText(strPath + "\\TwitterCrawlerLog_" + strDate + ".text", found); Console.Write("Log file written to desktop"); } Console.Read(); }
private InternetExplorer(SHDocVw.InternetExplorer browser) : base(Application.Attach(new IntPtr(browser.HWND), false)) { _browser = browser; _zoneId = NativeMethods.GetZoneId(_browser.LocationURL); }
private void DisposeAndCloseIE(bool closeIE) { if (!isDisposed) { if (closeIE && IsInternetExplorerStillAvailable()) { //TODO: Since HTMLDialog collection contains all HTMLDialogs // within the processId of this IE instance, there might be // other HTMLDialogs not created by this IE instance. Closing // also those HTMLDialogs seems not right. // So how will we handle this? For now we keep the "old" // implementation. // Close all open HTMLDialogs HtmlDialogs.CloseAll(); } base.Dispose(true); if (closeIE && IsInternetExplorerStillAvailable()) { // Ask IE to close ie.Quit(); } ie = null; if (closeIE) { // Wait for IE to close to prevent RPC errors when creating // a new WatiN.Core.IE instance. Thread.Sleep(1000); } isDisposed = true; } }
private Boolean InspectFrame(IHTMLElementCollection elementCollection, EnumerableRowCollection <DataRow> elementSearchProperties, object sender, SHDocVw.InternetExplorer browserInstance) { bool qualifyingElementFound = false; foreach (IHTMLElement element in elementCollection) // browserInstance.Document.All) { if (element.outerHTML != null) { string outerHtml = element.outerHTML.ToLower().Trim(); if (!outerHtml.StartsWith("<html") && !outerHtml.StartsWith("<body") && !outerHtml.StartsWith("<head") && !outerHtml.StartsWith("<!doctype")) { qualifyingElementFound = FindQualifyingElement(elementSearchProperties, element); if (qualifyingElementFound) { RunCommandActions(element, sender, browserInstance); lastElementCollectionFound = elementCollection; return(true); //break; } if (element.outerHTML != null && element.outerHTML.ToLower().Trim().StartsWith("<frame ")) { string frameId = element.getAttribute("id"); if (frameId == null) { frameId = element.getAttribute("name"); } if (frameId != null) { qualifyingElementFound = InspectFrame(browserInstance.Document.getElementById(frameId).contentDocument.all, elementSearchProperties, sender, browserInstance); } } if (qualifyingElementFound) { break; } } } } return(qualifyingElementFound); }
//public WebBrowserEvents(InternetExplorer _intExp, ref SWATWikiGenerator _write) //{ // _writer = _write; // Random rand = new Random(); // browserId = rand.Next(100000); // if (_intExp == null) // { // manualNavigation = true; // ie = new InternetExplorerClass(); // //add a property for identification // ie.PutProperty("ID", browserId); // ie.Visible = true; // object url = "about:blank"; // object nullObj = String.Empty; // ConnectWindow(ie); // ie.Navigate2(ref url, ref nullObj, ref nullObj, ref nullObj, ref nullObj); // HTMLEvents.lastBrowser = browserId; // } // else // { // manualNavigation = false; // ie = _intExp; // ie.PutProperty("ID", browserId); // ConnectWindow(ie); // } //} public WebBrowserEvents(String flag, SHDocVw.InternetExplorer _intExp, ref SWATWikiGenerator _write) { _writer = _write; Random rand = new Random(); browserId = rand.Next(100000); if (flag.Equals("AttachToWindow")) { init = false; manualNavigation = false; ie = _intExp; ie.PutProperty("ID", browserId); ConnectWindow(ie); //Debug.WriteLine((((HTMLDocument)ie.Document).frames).length); try { FramesCollection frames = (((HTMLDocument)ie.Document).frames); for (int i = 0; i < frames.length; i++) { object refIndex = i; try { HTMLDocument doc = (HTMLDocument)((HTMLWindow2Class)frames.item(ref refIndex)).document; if (doc.Equals((HTMLDocument)ie.Document)) continue; HTMLEvents aEvent = new HTMLEvents(_writer, doc, ie); _eventsList.Add(aEvent); } catch (UnauthorizedAccessException) { } } } catch (Exception) { } _eventsList.Insert(0, new HTMLEvents(_writer, ie.Document, ie)); checkAttach(); } else if (flag.Equals("NewWindow")) { manualNavigation = true; ie = new InternetExplorerClass(); //add a property for identification ie.PutProperty("ID", browserId); ie.Visible = true; object url = "about:blank"; object nullObj = String.Empty; ConnectWindow(ie); ie.Navigate2(ref url, ref nullObj, ref nullObj, ref nullObj, ref nullObj); HTMLEvents.lastBrowser = browserId; } else if (flag.Equals("PopUp")) { manualNavigation = false; ie = _intExp; ie.PutProperty("ID", browserId); ConnectWindow(ie); } else if (flag.Equals("AttachToModalWindow")) { IntPtr dialogHwnd = IntPtr.Zero; //int indexCount = NativeMethods.GetWindowWithSubstring("content.html", 0, 0, ref dialogHwnd); dialogHwnd = NativeMethods.GetForegroundWindow(); if (dialogHwnd != IntPtr.Zero) { // This block of code SHOULD take a window handle and return an IHTMLDocument object to dialogDoc // Then it will assign that object to _doc. It follows an example in the MSDN library and WatiN uses it as well. // If it performs correctly, then we should be attached to the Dialog. dialogHwnd = NativeMethods.GetChildWindowHwnd(dialogHwnd, "Internet Explorer_Server"); //dialogHwnd = NativeMethods.GetForegroundWindow(); Int32 result = 0; Int32 dialog; Int32 message; message = NativeMethods.RegisterWindowMessage("WM_HTML_GETOBJECT"); NativeMethods.SendMessageTimeout(dialogHwnd, message, 0, 0, NativeMethods.SMTO_ABORTIFHUNG, 1000, ref result); //NativeMethods.SendMessage(dialogHwnd, NativeMethods.WM_CLOSE, 0, 0); IHTMLDocument2 dialogDoc = null; System.Guid dialogID = typeof(mshtml.HTMLDocument).GUID; dialog = NativeMethods.ObjectFromLresult(result, ref dialogID, 0, ref dialogDoc); //HTMLFrameBase dialogDoc = null; //System.Guid dialogID = typeof(mshtml.HTMLFrameBase).GUID; //dialog = NativeMethods.ObjectFromLresult(result, ref dialogID, 0, ref dialogDoc); //dialogDoc.title = "Hello?"; //IHTMLDialog dialogDoc = null; //System.Guid dialogID = typeof(mshtml.HTMLDialog).GUID; //dialog = NativeMethods.ObjectFromLresult(result, ref dialogID, 0, ref dialogDoc); //IHTMLWindow2 dialogDoc = null; //System.Guid dialogID = typeof(IHTMLWindow2).GUID; //dialog = NativeMethods.ObjectFromLresult(result, ref dialogID, 0, ref dialogDoc); //dialogDoc.close(); //Console.WriteLine("URL: " + dialogDoc.close + "\nTitle: " + dialogDoc.title); //ie = (InternetExplorer)dialogDoc; //ie.PutProperty("ID", browserId); //ConnectWindow(ie); //doc = (HTMLDocument)dialogDoc; } } _browserList.Add(this); }
private void InitIEAndStartDialogWatcher(SHDocVw.InternetExplorer internetExplorer, Uri uri) { ie = internetExplorer; // Due to UAC in Vista the navigate has to be done // before showing the new Internet Explorer instance if (uri != null) { navigateTo(uri); } ie.Visible = Core.Settings.MakeNewIeInstanceVisible; StartDialogWatcher(); }
public WebProc(string urlAddress = null) { ie = new SHDocVw.InternetExplorer(); ie.DocumentComplete += Ie_DocumentComplete; webUrl = urlAddress; }
public IETabWindow(SHDocVw.InternetExplorer tab) : base(new IntPtr(tab.HWND)) { this.title = tab.LocationName + " - Internet Explorer"; this.ie = tab; Console.Write(this.handle); }
public sealed override async Task <Tuple <string, LinkFetchResult> > GetSourceLink(string url) { var ie = new IE(); //Create new browser (IE) ie.Navigate2(url); while (ie.ReadyState != tagREADYSTATE.READYSTATE_COMPLETE) { } await Pause(DelayInMilliseconds); Browser browser = ((Browser)ie); HTMLDocument doc = ((HTMLDocument)browser.Document); //Get document IHTMLElement button = doc.getElementById("btn_download"); //Define HTML button button.click(); string tempFile = $"{System.IO.Path.GetTempPath()}{Guid.NewGuid().ToString()}.lf.html"; await JavaScriptProcessingTime(); doc = ((HTMLDocument)browser.Document); using (var output = new FileStream(tempFile, FileMode.Append, FileAccess.Write, FileShare.ReadWrite)) { byte[] buffer = ASCIIEncoding.UTF8.GetBytes(((HTMLDocument)browser.Document).documentElement.outerHTML); await output.WriteAsync(buffer, 0, buffer.Length); } var line = string.Empty; var input = new StreamReader(tempFile); Match match = null; while ((line = input.ReadLine()) != null) //Scan file for link. { if (line == "") { continue; } match = _sourceUrlPattern.Match(line); if (match.Success) { break; } } var sourceUrl = string.Empty; var response = LinkFetchResult.SUCCESSFULL; if (match.Success) { sourceUrl = match.Groups[1].Value; } else { response = LinkFetchResult.FAILED; } return(new Tuple <string, LinkFetchResult>(sourceUrl, response)); }