Ejemplo n.º 1
0
        public A11yElement LocateRootElement(int processId)
        {
            try
            {
                var element = A11yAutomation.ElementFromProcessId(processId);

                return(new ElementContext(element).Element);
            }
            catch (Exception ex)
            {
                throw new AxeWindowsAutomationException(string.Format(CultureInfo.InvariantCulture, DisplayStrings.ErrorFailToGetRootElementOfProcess, processId, ex), ex);
            }
        }
Ejemplo n.º 2
0
        public A11yElement LocateRootElement(int processId)
        {
            try
            {
                var element = A11yAutomation.ElementFromProcessId(processId);

                #pragma warning disable CA2000 // Call IDisposable.Dispose()
                return(new ElementContext(element).Element);

                #pragma warning restore CA2000
            }
            catch (Exception ex)
            {
                throw new AxeWindowsAutomationException(string.Format(CultureInfo.InvariantCulture, DisplayStrings.ErrorFailToGetRootElementOfProcess, processId, ex), ex);
            }
        }
        /// <summary>
        /// Locate the target element in the UIA tree
        /// </summary>
        /// <param name="parameters">The caller-provided parameters</param>
        /// <returns>The ElementContext that matches the targeting parameters</returns>
        internal static ElementContext LocateElement(CommandParameters parameters)
        {
            if (parameters.TryGetLong(CommandConstStrings.TargetProcessId, out long parameterPid))
            {
                try
                {
                    var element = A11yAutomation.ElementFromProcessId((int)parameterPid);

                    return(new ElementContext(element));
                }
                catch (Exception ex)
                {
                    throw new A11yAutomationException(string.Format(CultureInfo.InvariantCulture, DisplayStrings.ErrorFailToGetRootElementOfProcess, parameterPid, ex), ex);
                }
            }

            throw new A11yAutomationException(DisplayStrings.ErrorNoProcessIdSet);
        }