Пример #1
0
        public override FocusType GetFocusType(IAccessible accessibleObject, out string url)
        {
            url = null;

            // Walk up tree finding parent
            var parent = accessibleObject;

            while (parent != null)
            {
                var role = AccessibleObjectHelper.GetRole(parent);
                if (role == AccessibleRole.Text && AccessibleObjectHelper.HasState(accessibleObject, AccessibleStates.Focusable))
                {
                    // Could be the location bar, if the parent is a grouping
                    if (accessibleObject.accParent is IAccessible immediateParent)
                    {
                        if (AccessibleObjectHelper.GetRole(immediateParent) == AccessibleRole.Grouping && (AccessibleStates)immediateParent.accState[0] == AccessibleStates.None)
                        {
                            return(FocusType.Location);
                        }
                        else
                        {
                            if (AccessibleObjectHelper.FindAncestor(immediateParent, AccessibleRole.Dialog) != null)
                            {
                                return(FocusType.FindInPage);
                            }
                        }
                    }
                }
                parent = parent.accParent as IAccessible;
            }

            return(FocusType.Other);
        }
Пример #2
0
        public override FocusType GetFocusType(IAccessible accessibleObject, out string url)
        {
            url = null;

            // Walk up tree finding parent
            var parent = accessibleObject;

            while (parent != null)
            {
                var role = AccessibleObjectHelper.GetRole(parent);
                if (role == AccessibleRole.ToolBar)
                {
                    // This is on the toolbar, so either location box or search box
                    if (accessibleObject.accParent is IAccessible immediateParent)
                    {
                        if (AccessibleObjectHelper.GetRole(immediateParent) == AccessibleRole.ComboBox)
                        {
                            if (AccessibleObjectHelper.HasState(accessibleObject, AccessibleStates.HasPopup))
                            {
                                return(FocusType.Location);
                            }
                            else
                            {
                                return(FocusType.Search);
                            }
                        }
                        else
                        {
                            if (parent.accParent is IAccessible propertyPage &&
                                AccessibleObjectHelper.GetRole(propertyPage) == AccessibleRole.PropertyPage)
                            {
                                // Get URL for page
                                var document = AccessibleObjectHelper.FindChild(AccessibleObjectHelper.FindChild(propertyPage),
                                                                                role: AccessibleRole.Document);
                                if (document != null)
                                {
                                    url = AccessibleObjectHelper.GetValue(document);
                                }
                            }

                            return(FocusType.FindInPage);
                        }
                    }
                }
                else if (role == AccessibleRole.Document && AccessibleObjectHelper.HasState(accessibleObject, AccessibleStates.Focusable))
                {
                    // This is a web page
                    url = AccessibleObjectHelper.GetValue(parent);
                    return(FocusType.Page);
                }
                parent = parent.accParent as IAccessible;
            }

            return(FocusType.Other);
        }
Пример #3
0
        private void OnEventReceived(IntPtr hWinEventHook, uint eventType, IntPtr hwnd, int idObject, int idChild, uint dwEventThread, uint dwmsEventTime)
        {
            if (idObject == GOOGLE_CHROME_ACCESSIBILITY_OBJECT_ID)
            {
                EventReceived = true;
                SendMessage(hwnd, WM_GETOBJECT, 0, idObject);

                // Chrome only enables accessibility if it gets a top-level IAccessible request, so let's make one first
                var _ = AccessibleObjectHelper.GetAccessibleObjectFromWindow(hwnd).accName;
            }
        }
Пример #4
0
        public override FocusType GetFocusType(IAccessible accessibleObject, out string url)
        {
            url = null;

            // Walk up tree finding parent
            var parent = accessibleObject;

            while (parent != null)
            {
                var role = AccessibleObjectHelper.GetRole(parent);
                if (role == AccessibleRole.Document && AccessibleObjectHelper.HasState(accessibleObject, AccessibleStates.Focusable))
                {
                    // This is a web page
                    url = AccessibleObjectHelper.GetValue(parent);
                    return(FocusType.Page);
                }

                parent = parent.accParent as IAccessible;
            }

            return(FocusType.Other);
        }