예제 #1
0
        private int GetTabIndexToActivateByTitle(string titlePart)
        {
            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 (!string.IsNullOrEmpty(tab.Title))
                        {
                            if (tab.Title.ToLower().Contains(titlePart.ToLower()))
                            {
                                return(index);
                            }
                        }
                        index++;
                    }
                }
            }

            return(-1);
        }
예제 #2
0
        internal void ActivateTab(string by, string phrase)
        {
            int tabIndexToActivate = 0;

            if (by.ToLower() == "title")
            {
                tabIndexToActivate = GetTabIndexToActivateByTitle(phrase);
            }
            else if (by.ToLower() == "url")
            {
                tabIndexToActivate = GetTabIndexToActivateByUrl(phrase);
            }

            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++;
                    }
                }
            }
        }