internal void ActivateByTabsUrl(string tabsUrl) { var tabIndexToActivate = GetTabIndexToActivate(tabsUrl); AccessibleObjectFromWindow(GetDirectUihWnd(_hWnd), ObjId.ObjIdWindow, 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++; } } } }
private int GetTabIndexToActivate(string tabsUrl) { AccessibleObjectFromWindow(GetDirectUihWnd(_hWnd), ObjId.ObjIdWindow, 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) { var tabUrl = tab.LocationUrl; if (!string.IsNullOrEmpty(tabUrl)) { if (tab.LocationUrl.Contains(tabsUrl)) { return(index); } } index++; } } } return(-1); }