public void Execute(Arguments arguments) { if (IEManager.SwitchIE(arguments.Id.Value) == false) { throw new InvalidOperationException($"Internet Instance with specified Id: '{arguments.Id.Value}' could not be found."); } }
internal void ActivateTab(string by, string phrase) { TabSearchBy searchBy; if (Enum.TryParse(by.CapitalizeFirstLetter(), out searchBy) == false) { throw new ApplicationException("Argument 'by' is not correct"); } int tabIndexToActivate = 0; switch (searchBy) { case TabSearchBy.Title: tabIndexToActivate = GetTabIndexToActivateByTitle(phrase); break; case TabSearchBy.Url: tabIndexToActivate = GetTabIndexToActivateByUrl(phrase); break; } AccessibleObjectFromWindow(GetDirectUIHWND(_hWnd), OBJID.OBJID_WINDOW, ref _accessible); CheckForAccessible(); var index = 0; var ieDirectUIHWND = new TabActivator(_hWnd); foreach (var accessor in ieDirectUIHWND.Children) { foreach (var child in accessor.Children) { foreach (var tab in child.Children) { if (tabIndexToActivate >= child.ChildCount - 1) { return; } if (index == tabIndexToActivate) { tab.ActivateTab(); var activeIe = IEManager.launchedIE?.Where(ie => ie.Ie.hWnd == _hWnd).FirstOrDefault(); if (activeIe != null) { IEManager.SwitchIE(activeIe.Id); } return; } index++; } } } }