Exemplo n.º 1
0
        private void OnF9Pressed()
        {
            Hashtable     ElemDetails = UIControl.GetMouseOverElemDetails();
            StringBuilder Details     = new StringBuilder();

            foreach (string key in ElemDetails.Keys)
            {
                Details.AppendLine(key + ": " + ElemDetails[key]);
            }
            MessageBox.Show(Details.ToString());
        }
Exemplo n.º 2
0
        private void OnF10Pressed()
        {
            Hashtable _ElemHash = UIControl.GetMouseOverElemDetails();

            //Clear existing items in both Controls' and SubControls' stackpanels.
            patternWin.stkControlTypes.Children.Clear();
            patternWin.stkSubControlTypes.Children.Clear();
            AutomationPattern[] SupportedPatterns = ((AutomationElement)_ElemHash["Element"]).GetSupportedPatterns();

            //Add buttons to SupportPattern stackpanel.
            foreach (AutomationPattern Pattern in SupportedPatterns)
            {
                Button but = new Button()
                {
                    Background  = Brushes.White,
                    BorderBrush = Brushes.DarkBlue,
                };
                but.Content = Pattern.ProgrammaticName;

                //This event sends Element Details (Hashtable) and the Button itself to Handler.
                but.Click += delegate(object sender, RoutedEventArgs e)
                {
                    stkItemClicked(sender, e, _ElemHash, ((AutomationElement)_ElemHash["Element"]));
                };

                //Adds the button to ControlType (SupportedPattern) stackpanel.
                patternWin.stkControlTypes.Children.Add(but);
            }

            //For other common element based actions.
            Button CommonButton = new Button()
            {
                Background  = Brushes.White,
                BorderBrush = Brushes.DarkBlue,
            };

            CommonButton.Content = "Common";
            CommonButton.Click  += delegate(object sender, RoutedEventArgs e)
            {
                stkItemClicked(sender, e, _ElemHash, ((AutomationElement)_ElemHash["Element"]));
            };
            patternWin.stkControlTypes.Children.Add(CommonButton);

            if (!patternWin.IsVisible)
            {
                patternWin.ShowDialog();
            }
        }