private int GetTabIndexToActivate(string tabsUrl) { AccessibleObjectFromWindow(GetDirectUIHWND(_hWnd), OBJID.OBJID_WINDOW, ref _accessible); CheckForAccessible(); var index = 0; var ieDirectUIHWND = new TabActivator(_hWnd); Uri myUri = new Uri(tabsUrl); string host = myUri.Host; foreach (var accessor in ieDirectUIHWND.Children) { foreach (var child in accessor.Children) { foreach (var tab in child.Children) { var tabUrl = tab.LocationUrl; if (!string.IsNullOrEmpty(tabUrl)) { if (tab.LocationUrl.Contains(host)) return index; } index++; } } } return -1; }
internal void ActivateByTabsUrl(string tabsUrl) { var tabIndexToActivate = GetTabIndexToActivate(tabsUrl); 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(); return; } index++; } } } }