public MsCrmWrapper(int id, string name, string by = "title", bool mscrmRecorder = false) { Ie = null; try { this.Id = id; string search = name.ToLower(); IECollection list = IE.InternetExplorers(); foreach (var item in list) { if (by.ToLower() == "title") { if (item.Title.ToLower().Contains(search)) { Ie = item; break; } } else { if (item.Url.ToLower().Contains(search)) { Ie = item; break; } } } if (Ie != null) { Address = Ie.Url; } } catch { throw new TimeoutException("Timeout occured while attaching to Internet Explorer / CRM"); } if (mscrmRecorder && Ie?.InternetExplorer != null) { MsCrmRecordingSwitch = true; SHDocVw.InternetExplorer webBrowser = (SHDocVw.InternetExplorer)Ie.InternetExplorer; webBrowser.DocumentComplete += ReinjectJavascriptListeners; object unimportant = null; ReinjectJavascriptListeners(null, ref unimportant); } }
/// <summary> /// Finds the new IE. /// </summary> /// <returns></returns> private static IE FindNewIE() { var browsers = new IECollection(true); return(browsers.Where(browser => browser.Url == urlEmpty && browser.hWnd == instances[0].hWnd).FirstOrDefault()); }
/// <summary> /// Creates an instance of WindowCollection and collects all of the visible windows. /// </summary> public WindowCollection() { _windows = IE.InternetExplorers(); }