public static List <BrowserIds> ListCollectInternetExplorerInstances() { var enumerator = new WindowsEnumerator(); List <BrowserIds> _browser = new List <BrowserIds>(); var topLevelWindows = enumerator.GetTopLevelWindows("IEFrame"); foreach (var mainBrowserWindow in topLevelWindows) { var windows = enumerator.GetChildWindows(mainBrowserWindow.Hwnd, "TabWindowClass"); // IE6 has no TabWindowClass so use the IEFrame as starting point if (windows.Count == 0) { windows.Add(mainBrowserWindow); } foreach (var window in windows) { _browser.Add(new BrowserIds { ProcessID = window.ProcessID, HWND = window.Hwnd.ToString(), Title = window.Title }); } } return(_browser); }
public static bool ActivateChrome(string title) { //AutoIt.AutoItX.AutoItSetOption("WinTitleMatchMode", 2); var searchString = title; var enumerator = new WindowsEnumerator(); List <string> tabs = new List <string>(); var topLevelWindows = enumerator.GetTopLevelWindows("Chrome_WidgetWin_1"); foreach (var mainBrowserWindow in topLevelWindows) { tabs = new List <string>(); AutoIt.AutoItX.WinActivate(mainBrowserWindow.Hwnd); for (int i = 0; i < 50; i++) { if (AutoIt.AutoItX.WinGetTitle("[ACTIVE]").Contains(searchString)) { AutoIt.AutoItX.WinSetState(searchString, "", AutoIt.AutoItX.SW_MAXIMIZE); // AutoIt.AutoItX.WinSetState(searchString, "", AutoIt.AutoItX.SW_SHOW); return(true); // } AutoIt.AutoItX.Send("^{TAB}"); //Thread.Sleep(250); if (tabs.Any() && tabs.Contains(AutoIt.AutoItX.WinGetTitle("[ACTIVE]"))) { break; } tabs.Add(AutoIt.AutoItX.WinGetTitle("[ACTIVE]")); } } return(false); }