当前位置: 首页>>代码示例>>C#>>正文


C# AutomationElement.GetCurrentPropertyValue方法代码示例

本文整理汇总了C#中System.Windows.Automation.AutomationElement.GetCurrentPropertyValue方法的典型用法代码示例。如果您正苦于以下问题:C# AutomationElement.GetCurrentPropertyValue方法的具体用法?C# AutomationElement.GetCurrentPropertyValue怎么用?C# AutomationElement.GetCurrentPropertyValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Automation.AutomationElement的用法示例。


在下文中一共展示了AutomationElement.GetCurrentPropertyValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestMoveWindow

 // CONSIDER: This will run on our automation thread
 //           Should be OK to call MoveWindow from there - it just posts messages to the window.
 void TestMoveWindow(AutomationElement listWindow, int xOffset, int yOffset)
 {
     var hwndList = (IntPtr)(int)(listWindow.GetCurrentPropertyValue(AutomationElement.NativeWindowHandleProperty));
     var listRect = (Rect)listWindow.GetCurrentPropertyValue(AutomationElement.BoundingRectangleProperty);
     Debug.Print("Moving from {0}, {1}", listRect.X, listRect.Y);
     Win32Helper.MoveWindow(hwndList, (int)listRect.X - xOffset, (int)listRect.Y - yOffset, (int)listRect.Width, 2 * (int)listRect.Height, true);
 }
开发者ID:Excel-DNA,项目名称:IntelliSense,代码行数:9,代码来源:WindowResizer.cs

示例2: ScrollItemPatternWrapper

        /// -------------------------------------------------------------------
        /// <summary></summary>
        /// -------------------------------------------------------------------
        internal ScrollItemPatternWrapper(AutomationElement element, string testSuite, TestPriorities priority, TypeOfControl typeOfControl, TypeOfPattern typeOfPattern, string dirResults, bool testEvents, IApplicationCommands commands)
            :
            base(element, testSuite, priority, typeOfControl, typeOfPattern, dirResults, testEvents, commands)
        {
            Comment("Creating ScrollItemTests");

            _pattern = (ScrollItemPattern)GetPattern(m_le, m_useCurrent, ScrollItemPattern.Pattern);
            if (_pattern == null)
                ThrowMe(CheckType.IncorrectElementConfiguration, Helpers.PatternNotSupported + ": ScrollItemPattern");

            // Find the ScrollPattern
            _container = m_le;

            while (_container != null && !(bool)_container.GetCurrentPropertyValue(AutomationElement.IsScrollPatternAvailableProperty))
                _container = TreeWalker.ControlViewWalker.GetParent(_container);

            // Check to see if we actual found the container of the scrollitem
            if (_container == null)
                ThrowMe(CheckType.IncorrectElementConfiguration, "Element does not have a container with ScrollPattern");

            Comment("Found scroll container: " + Library.GetUISpyLook(_container));

            _scrollPattern = (ScrollPattern)_container.GetCurrentPattern(ScrollPattern.Pattern) as ScrollPattern;

        }
开发者ID:jeffras,项目名称:uiverify,代码行数:28,代码来源:ScrollItemTests.cs

示例3: CreateNodeForAutomationElement

        /// <summary>
        /// Creates TreeNode for the AutomationElement
        /// </summary>
        public static TreeNode CreateNodeForAutomationElement(AutomationElement element, AutomationElementTreeControl parentControl)
        {
//            System.Diagnostics.Debug.WriteLine("CreateNodeForAutomationElement...");

            TreeNode node = new TreeNode(TreeHelper.GetAutomationElementTreeNodeText(element));
            node.Tag = new AutomationElementTreeNode(element, node, parentControl);

            if ((bool)element.GetCurrentPropertyValue(AutomationElement.IsContentElementProperty))
            {
                node.ForeColor = Color.Black; //.NodeFont = new Font(FontFamily.GenericSerif, 10, FontStyle.Bold);
            }
            else
            {
                node.ForeColor = Color.DarkGray;
            }


            /*************************************************/
            // this is only for test purposes, it makes the creation of each TreeNode slower
            //DateTime now = DateTime.Now;
            //DateTime endTime = now.AddMilliseconds(400);

            //while (DateTime.Now < endTime) ;
            /*************************************************/

//            System.Diagnostics.Debug.WriteLine("CreateNodeForAutomationElement EXIT");

            return node;
        }
开发者ID:geeksree,项目名称:cSharpGeeks,代码行数:32,代码来源:TreeHelper.cs

示例4: IsMeetsRequirements

        /// <summary>
        ///     Check to see if the specified automation element meets the requirements of the specified condition.
        /// </summary>
        /// <param name="condition">The condition to check.</param>
        /// <param name="element">The automation element to check.</param>
        /// <returns>True if the automation element meets the condition's requirements. False otherwise.</returns>
        public static bool IsMeetsRequirements(Condition condition, AutomationElement element)
        {
            var type = condition.GetType();
            if (condition == Condition.TrueCondition)
                // Always return true.
                return true;
            if (condition == Condition.FalseCondition)
                // Always returns false.
                return false;
            if (type == typeof(NotCondition))
                // Return the negation of the inner condition.
                return !IsMeetsRequirements(((NotCondition) condition).Condition, element);
            if (type == typeof(OrCondition))
                // Return true if any of the inner conditions are true.
                return ((OrCondition) condition).GetConditions().Any(inner => IsMeetsRequirements(inner, element));
            if (type == typeof(AndCondition))
                // Return true if all of the inner conditions are true.
                return ((AndCondition) condition).GetConditions().All(inner => IsMeetsRequirements(inner, element));
            if (type == typeof(StringPropertyCondition))
                // Return true if the string property condition matches.
                return ((StringPropertyCondition) condition).IsMatch(element);
            if (type == typeof(PropertyCondition)) {
                // Return true if the property condition matches.
                var propertyCondition = (PropertyCondition) condition;
                var actual = element.GetCurrentPropertyValue(propertyCondition.Property);
                var expected = propertyCondition.Value;

                Trace.WriteLine("Checking '" + AutomationPropertyHelper.ToString(actual) + "'='" + AutomationPropertyHelper.ToString(expected) + "'", "UIAutomation-ConditionHelper");
                return AutomationPropertyHelper.Equals(actual, expected);
            }
            // Don't know how to match any other conditions.
            throw new NotSupportedException("Condition '" + type + "' is not supported");
        }
开发者ID:vijayakumarsuraj,项目名称:UIAutomation,代码行数:39,代码来源:ConditionHelper.cs

示例5: LogProperties

 public static void LogProperties(AutomationElement element)
 {
     AutomationProperty[] automationProperties = element.GetSupportedProperties();
     foreach (AutomationProperty automationProperty in automationProperties)
     {
         Logger.Info(automationProperty.ProgrammaticName + ":" + element.GetCurrentPropertyValue(automationProperty));
     }
 }
开发者ID:ritro,项目名称:White,代码行数:8,代码来源:Debug.cs

示例6: IsMatch

 /// <summary>
 ///     Check if the specified automation element meets this condition's requirements.
 /// </summary>
 /// <param name="element">The element to check.</param>
 /// <returns>True if the automation element meets this condition's requirements.</returns>
 public bool IsMatch(AutomationElement element)
 {
     var actualObj = element.GetCurrentPropertyValue(Property);
     // If the element's current property value is null or not a string object, return false.
     if (actualObj == null || !(actualObj is string))
         return false;
     // Otherwise cast to strings...
     var actual = (string) actualObj;
     var expected = (string) Value;
     // ... and compare them.
     return Matcher.IsMatch(actual, expected);
 }
开发者ID:vijayakumarsuraj,项目名称:UIAutomation,代码行数:17,代码来源:StringPropertyCondition.cs

示例7: GetPatterns

        internal static string GetPatterns(AutomationElement element)
        {
            var properties = element.GetSupportedProperties();

            var msg = new StringBuilder();

            msg.Append("Supported Properties:\n");
            foreach (var automationProperty in properties)
            {
                var value = element.GetCurrentPropertyValue(automationProperty);
                msg.AppendFormat(CultureInfo.InvariantCulture, "{0}: {1}\n", automationProperty.ProgrammaticName, value);
            }

            return msg.ToString();
        }
开发者ID:NetlifeBackupSolutions,项目名称:Winium.StoreApps.CodedUi,代码行数:15,代码来源:GetSupportedAutomationExecutor.cs

示例8: GetClassName

        public static void GetClassName(AutomationElement autoElement, out string className, out string localizedControlType)
        {
            ValidateArgumentNonNull(autoElement, "AutomationElement argument cannot be null");  // Sanity check

            className = ""; // Initialize
            localizedControlType = "";

            // Get ClassName (edit, richedit and various flavors of each)
            className = GetClassName(autoElement);

            // get LocalizedControlType (needed for IPControl, etc.)
            localizedControlType = (string)autoElement.GetCurrentPropertyValue(AutomationElement.LocalizedControlTypeProperty);
            if (localizedControlType != null)
                localizedControlType = localizedControlType.ToUpperInvariant(); // Culture Invariant value for property
            else
                throw new InvalidOperationException("LocalizedControlType Property cannot return null");
        }
开发者ID:geeksree,项目名称:cSharpGeeks,代码行数:17,代码来源:TextLibraryCount.cs

示例9: AddAutomationEventHandler

        /// <summary>
        /// Called by a client to add a listener for pattern or custom events.
        /// </summary>
        /// <param name="eventId">A control pattern or custom event identifier.</param>
        /// <param name="element">Element on which to listen for control pattern or custom events.</param>
        /// <param name="scope">Specifies whether to listen to property changes events on the specified element, and/or its ancestors and children.</param>
        /// <param name="eventHandler">Delegate to call when the specified event occurs.</param>
        /// 
        /// <outside_see conditional="false">
        /// This API does not work inside the secure execution environment.
        /// <exception cref="System.Security.Permissions.SecurityPermission"/>
        /// </outside_see>
        public static void AddAutomationEventHandler(
            AutomationEvent eventId,
            AutomationElement element,
            TreeScope scope,
            AutomationEventHandler eventHandler
            )
        {
            Misc.ValidateArgumentNonNull(element, "element" );
            Misc.ValidateArgumentNonNull(eventHandler, "eventHandler" );
            Misc.ValidateArgument( eventId != AutomationElement.AutomationFocusChangedEvent, SRID.EventIdMustNotBeAutomationFocusChanged );
            Misc.ValidateArgument( eventId != AutomationElement.StructureChangedEvent,SRID.EventIdMustNotBeStructureChanged );
            Misc.ValidateArgument( eventId != AutomationElement.AutomationPropertyChangedEvent, SRID.EventIdMustNotBeAutomationPropertyChanged );

            if (eventId == WindowPattern.WindowClosedEvent)
            {
                // Once a window closes and the hwnd is destroyed we won't be able to determine where it was in the 
                // Automation tree; therefore only support WindowClosed events for all windows (eg. src==root and scope 
                // is descendants) or a specific WindowPattern element (src==root of a Window and scope is the element).
                // Also handle odd combinations (eg. src==specific element and scope is subtree|ancestors).

                bool paramsValidated = false;

                if ( Misc.Compare( element, AutomationElement.RootElement ) )
                {
                    // For root element need to have Descendants scope set (Note: Subtree includes Descendants)
                    if ( ( scope & TreeScope.Descendants ) == TreeScope.Descendants )
                    {
                        paramsValidated = true;
                    }
                }
                else
                {
                    // otherwise non-root elements must have the entire tree (Anscestors, Element and Descendants)...
                    if ( ( scope & ( TreeScope.Ancestors | TreeScope.Element | TreeScope.Descendants ) ) == ( TreeScope.Ancestors | TreeScope.Element | TreeScope.Descendants ) )
                    {
                        paramsValidated = true;
                    }
                    else if ( ( scope & TreeScope.Element ) == TreeScope.Element )
                    {
                        // ...OR Element where the element implements WindowPattern
                        // PRESHARP will flag this as warning 56506/6506:Parameter 'element' to this public method must be validated: A null-dereference can occur here.
                        // False positive, element is checked, see above
#pragma warning suppress 6506
                        object val = element.GetCurrentPropertyValue(AutomationElement.NativeWindowHandleProperty);
                        if ( val != null && val is int && (int)val != 0 )
                        {
                            if ( HwndProxyElementProvider.IsWindowPatternWindow( NativeMethods.HWND.Cast( new IntPtr( (int)val ) ) ) )
                            {
                                paramsValidated = true;
                            }
                        }
                    }
                }

                if ( !paramsValidated )
                {
                    throw new ArgumentException( SR.Get( SRID.ParamsNotApplicableToWindowClosedEvent ) );
                }
            }

            // Add a client-side Handler for for this event request
            EventListener l = new EventListener(eventId, scope, null, CacheRequest.CurrentUiaCacheRequest);
            ClientEventManager.AddListener(element, eventHandler, l);
        }
开发者ID:JianwenSun,项目名称:cc,代码行数:76,代码来源:Automation.cs

示例10: In

 public static bool In(this AutomationProperty property, AutomationElement element)
 {
     return (bool) element.GetCurrentPropertyValue(property);
 }
开发者ID:hbqy90,项目名称:RAutomation,代码行数:4,代码来源:Property.cs

示例11: ClickTheBatch

 private void ClickTheBatch(AutomationElement lstView,int batchID)
 {
     const int eachRowHeight = 19;
     int nPosition = 21 + eachRowHeight * batchID;
     System.Windows.Rect rect = (System.Windows.Rect)lstView.GetCurrentPropertyValue(AutomationElement.BoundingRectangleProperty);
     winMessenger.MouseMove((int)rect.Left + 100, (int)rect.Top + nPosition - eachRowHeight / 2);
     winMessenger.Click();
 }
开发者ID:kingofcrabs,项目名称:LuminexDriver,代码行数:8,代码来源:WindowOp.cs

示例12: AutomationElementGetCurrentPropertyValue

        public static void AutomationElementGetCurrentPropertyValue(AutomationElement element)
        {
            ArrayList automationProperties = null;
            ArrayList automationPatterns = null;
            Random rnd = new Random((int)DateTime.Now.Ticks);
            PopulateAutomationElementProperties(ref automationProperties, ref automationPatterns);
            AutomationProperty property = (AutomationProperty)automationProperties[rnd.Next(automationProperties.Count - 1)];

            Dump("GetCurrentPropertyValue(" + property + ")", true, element);
            try
            {
                object obj = element.GetCurrentPropertyValue(property);
            }
            catch (Exception exception)
            {
                VerifyException(element, exception,
                  typeof(ElementNotAvailableException),
                  typeof(InvalidOperationException) /* {"Operation is not valid due to the current state of the object."}*/
                  );
            }
        }
开发者ID:geeksree,项目名称:cSharpGeeks,代码行数:21,代码来源:stress.cs

示例13: TS_GetContainTableByNavigation

        /// -------------------------------------------------------------------
        /// <summary>
        /// Test step to get the containing table that has table pattern implemented
        /// </summary>
        /// -------------------------------------------------------------------
        void TS_GetContainTableByNavigation(AutomationElement element, out AutomationElement table, CheckType ct)
        {
            table = element;
            while (
                !(bool)table.GetCurrentPropertyValue(AutomationElement.IsTablePatternAvailableProperty)
                && element != AutomationElement.RootElement
                )
            {
                table = TreeWalker.RawViewWalker.GetParent(table);
                if (table == null)
                    ThrowMe(ct, "There were no ancestors that suupported TablePattern");
            }

            if (element == AutomationElement.RootElement)
                ThrowMe(ct, "Could not find parent element that supports TablePattern");

            Comment("Found containing table w/navigation(" + Library.GetUISpyLook(table) + ")");
            m_TestStep++;
        }
开发者ID:jeffras,项目名称:uiverify,代码行数:24,代码来源:TableItemTests.cs

示例14: HelperCheckBoxCurrentToggleState

 /// -------------------------------------------------------------------
 /// <summary></summary>
 /// -------------------------------------------------------------------
 bool HelperCheckBoxCurrentToggleState(AutomationElement element, ToggleState state)
 {
     Library.ValidateArgumentNonNull(element, "AutomationElement");
     return ((ToggleState)element.GetCurrentPropertyValue(TogglePattern.ToggleStateProperty) == state);
 }
开发者ID:TestStack,项目名称:UIAVerify,代码行数:8,代码来源:ScreenReader.cs

示例15: SetHighlightingElement

        /// <summary>
        /// this will set the highlighting rectangle upon automation element.
        /// </summary>
        /// <param name="selectedElement"></param>
        private void SetHighlightingElement(AutomationElement selectedElement)
        {
            if (selectedElement == null)
                SetVisibility(false); //if we do net have selected element then hide hilightling rectangle
            else
            {
                Rect rectangle = Rect.Empty;
                try
                {
                    //we will try to get bounding rectangle
                    rectangle = (Rect)selectedElement.GetCurrentPropertyValue(AutomationElement.BoundingRectangleProperty, true);
                }
                catch (Exception ex)
                {
                    //if it failed then log exception
                    ApplicationLogger.LogException(ex);
                }

                if (rectangle != Rect.Empty)
                {
                    //if we have rectangle then set the highlighting rectangle
                    this.Location = new Drawing.Rectangle((int)rectangle.Left, (int)rectangle.Top, (int)rectangle.Width, (int)rectangle.Height);
                    SetToolTip(selectedElement);
                    SetVisibility(true);
                }
                else
                {
                    //if we don't then hide hilightting rectangle
                    SetVisibility(false);
                }
            }
        }
开发者ID:geeksree,项目名称:cSharpGeeks,代码行数:36,代码来源:ElementHighlighter.cs


注:本文中的System.Windows.Automation.AutomationElement.GetCurrentPropertyValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。