Ejemplo n.º 1
1
        public bool checkHandle()
        {
            Guid guid = new Guid("{618736E0-3C3D-11CF-810C-00AA00389B71}");
            object obj = null;
            int retVal = AccessibleObjectFromWindow(handle, (uint)OBJID.WINDOW, ref guid, ref obj);
            iAccessible = (IAccessible)obj;

            //The AccWindowName returned is Add-ons Manager - Mozilla Firefox
            //There is a special child id called CHILDID_SELF (this constant equals 0) that, when used with a function like get_accChild, returns the element itself rather than a child.

            string accWindowName = iAccessible.get_accName(0);
            string accWindowVal = iAccessible.get_accValue(0);

            Console.WriteLine("IAccessible Name : " + accWindowName);
            Console.WriteLine("IAccessible value : " + accWindowVal);
            Console.WriteLine("IAccessible Role is : " + iAccessible.get_accRole(0));

            Console.WriteLine("IAccessible Type: " + iAccessible.GetType());
            Console.WriteLine("IAccessible Focus is: " + iAccessible.accFocus);
            Console.WriteLine("IAccessible Selection is " + iAccessible.get_accState());
            //iAccessible.accSelect((int)OBJID.SELFLAG_TAKEFOCUS, 0);
            if (!accWindowName.Contains("Mozilla Firefox"))
                return false;

            getChild(iAccessible,false);

            //End of for window
            Console.WriteLine("End of checkHandle");
            iAccessible = null;
            return false;
        }
Ejemplo n.º 2
0
        public bool checkHandle()
        {
            Guid   guid   = new Guid("{618736E0-3C3D-11CF-810C-00AA00389B71}");
            object obj    = null;
            int    retVal = AccessibleObjectFromWindow(handle, (uint)OBJID.WINDOW, ref guid, ref obj);

            iAccessible = (IAccessible)obj;

            //The AccWindowName returned is Add-ons Manager - Mozilla Firefox
            //There is a special child id called CHILDID_SELF (this constant equals 0) that, when used with a function like get_accChild, returns the element itself rather than a child.

            string accWindowName = iAccessible.get_accName(0);
            string accWindowVal  = iAccessible.get_accValue(0);

            Console.WriteLine("IAccessible Name : " + accWindowName);
            Console.WriteLine("IAccessible value : " + accWindowVal);
            Console.WriteLine("IAccessible Role is : " + iAccessible.get_accRole(0));

            Console.WriteLine("IAccessible Type: " + iAccessible.GetType());
            Console.WriteLine("IAccessible Focus is: " + iAccessible.accFocus);
            Console.WriteLine("IAccessible Selection is " + iAccessible.get_accState());
            //iAccessible.accSelect((int)OBJID.SELFLAG_TAKEFOCUS, 0);
            if (!accWindowName.Contains("Mozilla Firefox"))
            {
                return(false);
            }

            getChild(iAccessible, false);

            //End of for window
            Console.WriteLine("End of checkHandle");
            iAccessible = null;
            return(false);
        }
Ejemplo n.º 3
0
        public void UpdateState()
        {
            object state = IAccessible.get_accState(ChildId);

            if (!(state is int))
            {
                throw new VariantNotIntException(state);
            }

            State = (int)state;
        }
Ejemplo n.º 4
0
        private void SetAccessibleProperties()
        {
            //Here we are consuming the COM Exceptions which happens in case
            //the property/Method we need is not available with IAccessible Object.

            try
            {
                _name = _accessible.get_accName(0);
            }
            catch (Exception ex)
            {
            }

            try
            {
                _value = _accessible.get_accValue(0);
            }
            catch (Exception ex)
            {
            }

            try
            {
                uint stateId = Convert.ToUInt32(_accessible.get_accState(0));
                _state = MSAA.GetStateText(stateId);
            }
            catch (Exception ex)
            {
            }

            try
            {
                uint roleId = Convert.ToUInt32(_accessible.get_accRole(0));
                _role = MSAA.GetRoleText(roleId);
            }
            catch (Exception ex)
            {
            }


            _handle = MSAA.GetHandle(_accessible);

            try
            {
                _defaultAction = _accessible.get_accDefaultAction(0);
            }
            catch (Exception ex)
            {
            }

            SetLocation(_accessible);
        }
Ejemplo n.º 5
0
        internal static string GetState(IAccessible accObj, int childId)
        {
            int state = -1;

            try
            {
                state = (int)accObj.get_accState(childId);
            }
            catch (Exception exception)
            {
                if (!IsOleAccException(exception) || !IsOleAccExceptionMaskable(exception))
                {
                    throw;
                }
            }
            return(StringifyState(state));
        }
Ejemplo n.º 6
0
        internal static int GetStateValue(IAccessible accObj, int childId)
        {
            int num = -1;

            try
            {
                num = (int)accObj.get_accState(childId);
            }
            catch (Exception exception)
            {
                if (!IsOleAccException(exception) || !IsOleAccExceptionMaskable(exception))
                {
                    throw;
                }
                return(num);
            }
            return(num);
        }
Ejemplo n.º 7
0
 object?IAccessibleInternal.get_accState(object childID)
 => publicIAccessible.get_accState(childID);
 object UnsafeNativeMethods.IAccessibleInternal.get_accState(object childID)
 {
     IntSecurity.UnmanagedCode.Assert();
     return(publicIAccessible.get_accState(childID));
 }
Ejemplo n.º 9
0
        static int findIexplrTab(System.Diagnostics.Process iexplrProc, string findTxt, bool activateTab)
        {
            // [ https://stackoverflow.com/questions/3820228/setting-focus-to-already-opened-tab-of-internet-explorer-from-c-sharp-program-us ]
            IntPtr hWndDirectUI = GetDirectUIHWND(iexplrProc.MainWindowHandle);  if (hWndDirectUI == IntPtr.Zero)

            {
                return(int.MinValue);
            }

            // [ https://msdn.microsoft.com/en-us/library/system.windows.forms.accessibleobject(v=vs.110).aspx ]
            // [ https://www.codeproject.com/Articles/38906/UI-Automation-Using-Microsoft-Active-Accessibility ]
            Accessibility.IAccessible objAccessible = null;  getAccessibleObjectFromWindow(hWndDirectUI, ref objAccessible);
            if (objAccessible == null)
            {
                Console.WriteLine("ERROR: getAccessibleObjectFromWindow()");
                return(int.MinValue);
            }

            bool foundTab = false; int tabIndex = 0;

            foreach (IAccessible accessor in getAccessibleChildren(objAccessible))
            {
                foreach (IAccessible accChild in getAccessibleChildren(accessor))
                {
                    IAccessible[] accTabs = getAccessibleChildren(accChild);
                    for (int i = 0; i < accTabs.Length - 1; i++)
                    {
                        tabIndex++;  IAccessible accTab = accTabs[i];
                        if (findTxt.Length == 0)
                        {
                            if ((int)accTab.get_accState(0) == 0x200002) // 2097154
                            {
                                printIexplrTabInfo(iexplrProc, accTab, tabIndex, i);
                                Console.WriteLine("[activeTab:{0}]", tabIndex);
                                return(tabIndex);
                            }
                        }
                        else if (findTxt.Length > 0 && accTab.accDescription[0].Contains(findTxt))
                        {
                            foundTab = true;
                            printIexplrTabInfo(iexplrProc, accTab, tabIndex, i);
                            Console.WriteLine("[foundTab:{0}]", tabIndex);
                            if (activateTab && (int)accTab.get_accState(0) != 0x200002)
                            {
                                accTab.accDoDefaultAction(0); // 0==CHILDID_SELF ==> !!activate this tab!!
                                System.Threading.Thread.Sleep(200);
                                if ((int)accTab.get_accState(0) == 0x200002)
                                {
                                    Console.WriteLine("[activateTab:success]");
                                }
                                else
                                {
                                    Console.WriteLine("[activateTab:failed]");
                                }
                            }
                            return(tabIndex);
                        }
                    } // accTabs
                }     // accChild
            }         // accessor

            return(-tabIndex);
        }