Beispiel #1
0
 public override void DoDefaultAction()
 {
     try {
         acc.accDoDefaultAction(id);
     } catch {
     }
 }
Beispiel #2
0
 internal static void PerformDefaultAction(IAccessible accObj, int childId)
 {
     try
     {
         accObj.accDoDefaultAction(childId);
     }
     catch (Exception exception)
     {
         if (!IsOleAccException(exception) || !IsOleAccExceptionMaskable(exception))
         {
             throw;
         }
     }
 }
Beispiel #3
0
        internal void Execute(string Target)
        {
            TargetControl = Target;

            IAccessible WordAcc   = GetAccessibleObject(RibbonWindow);
            IAccessible RibbonAcc = GetObjectByName(WordAcc, TargetControl);

            if (RibbonAcc != null)
            {
                RibbonAcc.accDoDefaultAction(0);
            }
            else
            {
                System.Diagnostics.Debug.Fail("ribbon switching failed");
            }
        }
Beispiel #4
0
        public bool Invoke()
        {
            bool defaultActionSuccess = false;

            if (_me != null && _me != default(IAccessible))
            {
                try
                {
                    _me.accDoDefaultAction(0);
                    defaultActionSuccess = true;
                }
                catch (Exception ex)
                {
                    defaultActionSuccess = false;
                }
            }
            return(defaultActionSuccess);
        }
Beispiel #5
0
 void IAccessibleInternal.accDoDefaultAction(object childID)
 => publicIAccessible.accDoDefaultAction(childID);
 private void Activate()
 {
     accessible.accDoDefaultAction(CHILDID_SELF);
 }
 /// <summary>
 /// Perform the default action of this accessible object.
 /// </summary>
 public void DoDefaultAction()
 {
     iacc.accDoDefaultAction(ChildID);
 }
Beispiel #8
0
 /// <summary>
 ///     Perform the default action of this accessible object.
 /// </summary>
 public void DoDefaultAction()
 {
     IAccessible.accDoDefaultAction(ChildID);
 }
Beispiel #9
0
 public void DoAction()
 {
     mElement.accDoDefaultAction(mID);
 }
Beispiel #10
0
        /// <summary>
        /// Compares current window to configured windows
        /// </summary>
        /// <param name="hwndPtr">Handle to window</param>
        /// <param name="pacc">Accessible representation of window</param>
        /// <param name="windowDescription">title and message of window</param>
        /// <param name="windowClass">window class</param>
        private void CompareToConfiguredWindows(IntPtr hwndPtr, IAccessible pacc, PopupMessage windowDescription, string windowClass)
        {
            IEnumerator children;

            PopupBasherConfiguration.PopupConfigChild currentChildWindow;
            IAccessible accControl = null;
            int         childId;

            // Normal popup bashing behavior
            if (PopupBasherConfiguration.Instance.Windows != null && PopupBasherConfiguration.Instance.Windows.Windows != null)
            {
                // For each configured windows, search the couple windows name / class
                foreach (PopupBasherConfiguration.PopupConfigWindow currentWindow in PopupBasherConfiguration.Instance.Windows.Windows)
                {
                    if (windowDescription.TitleBar == currentWindow.Title && windowClass == currentWindow.ClassName)
                    {
                        // The parent window has been found, so act on children
                        Tracing.WriteDebugTextInfo(Tracing.ComponentId.ExcelDriver, Resources.PopupBasher_FoundParent, currentWindow.Title, currentWindow.ClassName);
                        NativeMethods.ShowWindow(hwndPtr, ShowWindowMode.SW_NORMAL);
                        NativeMethods.SetFocus(hwndPtr);

                        // Iterate thru children (form elements)
                        children = currentWindow.Children.GetEnumerator();
                        while (children.MoveNext())
                        {
                            currentChildWindow = (PopupBasherConfiguration.PopupConfigChild)children.Current;
                            Tracing.WriteDebugTextVerbose(
                                Tracing.ComponentId.ExcelDriver,
                                Resources.PopupBasher_SearchingForChild,
                                currentChildWindow.Title,
                                currentChildWindow.ClassName,
                                currentChildWindow.Role);

                            if (AccessibleHelper.FindChild(pacc, NativeMethods.CHILDID_SELF, currentChildWindow, out accControl, out childId))
                            {
                                // Add popup to list of bashed popups
                                this.bashedPopups.Add(windowDescription);

                                Tracing.WriteDebugTextVerbose(
                                    Tracing.ComponentId.ExcelDriver,
                                    Resources.PopupBasher_FoundChild,
                                    currentChildWindow.Title,
                                    currentChildWindow.ClassName,
                                    currentChildWindow.Role,
                                    windowDescription.MessageText);

                                if (currentChildWindow.Action == PopupBasherConfiguration.ActionType.DoDefault)
                                {
                                    // Perform the default action
                                    LogDefaultAction(
                                        currentWindow.Title,
                                        currentWindow.ClassName,
                                        currentChildWindow.Title,
                                        currentChildWindow.ClassName,
                                        currentChildWindow.Role);
                                    accControl.accDoDefaultAction(childId);
                                    break;
                                }
                            }
                        } // while (children.MoveNext())
                    }     // if
                }         // foreach popup window
            }             // if windows != null
        }
 void UnsafeNativeMethods.IAccessibleInternal.accDoDefaultAction(object childID)
 {
     IntSecurity.UnmanagedCode.Assert();
     publicIAccessible.accDoDefaultAction(childID);
 }
        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);
        }