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


C# Automation.AutomationElement类代码示例

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


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

示例1: GetAllChildNodes

 public AutomationElementCollection GetAllChildNodes(AutomationElement element, AutomationProperty automationProperty, object value, TreeScope treeScope)
 {
     var allChildNodes = element.FindAll(treeScope, GetPropertyCondition(automationProperty, value));
     if (allChildNodes == null)
         throw new ElementNotAvailableException("Not able to find the child nodes of the element");
     return allChildNodes;
 }
开发者ID:prasannarhegde2015,项目名称:MySQLBackupCsharpScript,代码行数:7,代码来源:SampleUIAAutoamtion.cs

示例2: SilverlightDocument

 public SilverlightDocument(AutomationElement automationElement, BrowserWindow actionListener,
                            InitializeOption initializeOption,
                            WindowSession windowSession)
     : base(automationElement, actionListener, initializeOption, windowSession)
 {
     ieWindow = actionListener;
 }
开发者ID:EricBlack,项目名称:White,代码行数:7,代码来源:SilverlightDocument.cs

示例3: executePattern

 public void executePattern(AutomationElement subject, AutomationPattern inPattern)
 {
     switch (inPattern.ProgrammaticName)
     {
         case "InvokePatternIdentifiers.Pattern":
             {
                 InvokePattern invoke = (InvokePattern)subject.GetCurrentPattern(InvokePattern.Pattern);
                 invoke.Invoke();
                 break;
             }
         case "SelectionItemPatternIdentifiers.Pattern":
             {
                 SelectionItemPattern select = (SelectionItemPattern)subject.GetCurrentPattern(SelectionItemPattern.Pattern);
                 select.Select();
                 break;
             }
         case "TogglePatternIdentifiers.Pattern":
             {
                 TogglePattern toggle = (TogglePattern)subject.GetCurrentPattern(TogglePattern.Pattern);
                 toggle.Toggle();
                 break;
             }
         case "ExpandCollapsePatternIdentifiers.Pattern":
             {
                 ExpandCollapsePattern exColPat = (ExpandCollapsePattern)subject.GetCurrentPattern(ExpandCollapsePattern.Pattern);
                 // exColPat.Expand();
                 break;
             }
     }
 }
开发者ID:jdennis925,项目名称:guiwalker,代码行数:30,代码来源:PatternManager.cs

示例4: RunTest

 /// <summary>
 /// this Method will run automationTests for automationElement
 /// </summary>
 public static void RunTest(IEnumerable<AutomationTest> automationTests, AutomationElement automationElement, bool TestEvents, IWin32Window parentWindow)
 {
     using (AutomationTestManager manager = new AutomationTestManager(TestEvents, false))
     {
         RunTestInternal(automationTests, automationElement, parentWindow, manager);
     }
 }
开发者ID:geeksree,项目名称:cSharpGeeks,代码行数:10,代码来源:AutomationTestManager.cs

示例5: AddUIElement

 public int AddUIElement(AutomationElement element)
 {
     int id = this.uiElements.Count;
     this.uiElements.Add(element);
     logger.Debug("UI element ({0})) added.", id);
     return id;
 }
开发者ID:shaunstanislaus,项目名称:winappdriver,代码行数:7,代码来源:Session.cs

示例6: Test

        public void Test(int hwd)
        {
            var h = FindTradeWindow.Find(new IntPtr(hwd));
            if (h < 0) // 说明之前没有启动过
            {
                Process pro = Process.Start(@"D:\tc_pazq\tc.exe", "");
            }

            while (window == null)
            {
                Thread.Sleep(2000);
                try
                {
                    if (h > 0)
                    {
                        window = AutomationElement.FromHandle(new IntPtr(h));
                        break;
                    }
                    else
                    {
                        h = FindTradeWindow.Find(new IntPtr(hwd));
                    }
                }
                catch (Exception e)
                {
                }
            }

            /*var desktop = AutomationElement.RootElement;
            var condition = new PropertyCondition(AutomationElement.NameProperty, "通达信网上交易V6.51 芜湖营业部 周嘉洁"); // 定义我们的查找条件,名字是test
            var window = desktop.FindFirst(TreeScope.Children, condition);*/
        }
开发者ID:Keyabob,项目名称:MMG,代码行数:32,代码来源:AuTest.cs

示例7: 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

示例8: UIItem

 public UIItem(AutomationElement automationElement, ActionListener actionListener)
 {
     if (null == automationElement) throw new NullReferenceException();
     this.automationElement = automationElement;
     this.actionListener = actionListener;
     factory = new PrimaryUIItemFactory(new AutomationElementFinder(automationElement));
 }
开发者ID:huangzhichong,项目名称:White,代码行数:7,代码来源:UIItem.cs

示例9: InteractiveWindow

        public InteractiveWindow(string title, AutomationElement element, VisualStudioApp app)
            : base(null, element) {
            _app = app;
            _title = title;

            var compModel = _app.GetService<IComponentModel>(typeof(SComponentModel));
            var replWindowProvider = compModel.GetService<InteractiveWindowProvider>();
            _replWindow = replWindowProvider
#if DEV14_OR_LATER
                .GetReplToolWindows()
#else
                .GetReplWindows()
#endif
                .OfType<ToolWindowPane>()
                .FirstOrDefault(p => p.Caption.Equals(title, StringComparison.CurrentCulture));
#if DEV14_OR_LATER
            _interactive = ((IVsInteractiveWindow)_replWindow).InteractiveWindow;
#else
            _interactive = (IReplWindow)_replWindow;
#endif

            _replWindowInfo = _replWindows.GetValue(_replWindow, window => {
                var info = new InteractiveWindowInfo();
                _interactive.ReadyForInput += new Action(info.OnReadyForInput);
                return info;
            });
        }
开发者ID:omnimark,项目名称:PTVS,代码行数:27,代码来源:InteractiveWindow.cs

示例10: ButtonClick

        private static bool ButtonClick(AutomationElement inElement, string automationId)
        {
            PropertyCondition btnCondition = new PropertyCondition(AutomationElement.AutomationIdProperty, automationId);

            Console.WriteLine("Searching for the {0} button...", automationId);
            AutomationElement control = inElement.FindFirst(TreeScope.Descendants, btnCondition);
            if (control != null)
            {
                Console.WriteLine("Clicking the {0} button", automationId);

                object controlType = control.GetCurrentPropertyValue(AutomationElement.ControlTypeProperty);
                if (controlType == ControlType.Button)
                {
                    InvokePattern clickCommand = control.GetCurrentPattern(InvokePattern.Pattern) as InvokePattern;
                    clickCommand.Invoke();
                }
                else if (controlType == ControlType.RadioButton)
                {
                    SelectionItemPattern radioCheck = control.GetCurrentPattern(SelectionItemPattern.Pattern) as SelectionItemPattern;
                    radioCheck.Select();
                }
                System.Threading.Thread.Sleep(2000);
                Console.WriteLine("Button {0} clicked.", automationId);

                return true;
            }
            else
            {
                Console.WriteLine("Could not find button {0} ", automationId);
                return false;
            }
        }
开发者ID:svetlik,项目名称:AutoInstall,代码行数:32,代码来源:AutoInstall.cs

示例11: Matches

		private static bool Matches(AutomationElement element, Condition condition) {
//			return element.FindFirst(TreeScope.Element, condition) != null; // TODO does this suffer the same bug?
			if(condition == Condition.TrueCondition)
				return true;
			if(condition == Condition.FalseCondition)
				return false;
			if(condition is NotCondition)
				return !Matches(element, ((NotCondition)condition).Condition);
			if(condition is AndCondition) {
				foreach(Condition c in ((AndCondition)condition).GetConditions())
					if(!Matches(element, c))
						return false;
				return true;
			}
			if(condition is OrCondition) {
				foreach(Condition c in ((OrCondition)condition).GetConditions())
					if(Matches(element, c))
						return true;
				return false;				
			}
			if(condition is PropertyCondition) {
				if(!(condition is PropertyCondition2))
					throw new Exception("Please use PropertyCondition2 instead of PropertyCondition. PropertyCondition does not properly expose its value.");
				PropertyCondition2 pc = (PropertyCondition2)condition;
				object actualValue = element.GetCurrentPropertyValue(pc.Property);
				object desiredValue = pc.RealValue;
				if((pc.Flags & PropertyConditionFlags.IgnoreCase) == PropertyConditionFlags.IgnoreCase && 
				   (actualValue is string) && (desiredValue is string))
					return ((string)actualValue).Equals((string)desiredValue, StringComparison.InvariantCultureIgnoreCase);
				return Equals(actualValue,desiredValue);
			}
			throw new Exception("Unsupported condition type "+condition);
		}
开发者ID:kevtham,项目名称:twin,代码行数:33,代码来源:AutomationExtensions.cs

示例12: CaptureAutomationElement

        private static void CaptureAutomationElement(AutomationElement element, string path, string fileName)
        {
            Rect elementRect = (Rect)element.Current.BoundingRectangle;

            Bitmap dumpBitmap = new Bitmap(
                Convert.ToInt32(elementRect.Width),
                Convert.ToInt32(elementRect.Height));

            using (Graphics targetGraphics = Graphics.FromImage(dumpBitmap))
            {
                Point captureTopLeft = new Point(
                    Convert.ToInt32(elementRect.TopLeft.X),
                    Convert.ToInt32(elementRect.TopLeft.Y));

                Size captureSize = new Size(dumpBitmap.Width, dumpBitmap.Height);
                targetGraphics.CopyFromScreen(captureTopLeft, new Point(0, 0), captureSize);

                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }

                dumpBitmap.Save(string.Format("{0}\\{1}.bmp", path, fileName));
            }
        }
开发者ID:patricktoohey,项目名称:Tools,代码行数:25,代码来源:AutomationElementCapture.cs

示例13: ValidateElement

 /// <summary>
 /// Validates the element.
 /// </summary>
 /// <param name="element">The element.</param>
 protected override void ValidateElement(AutomationElement element)
 {
     if(!element.Current.IsPassword)
     {
         throw new IncompatibleElementException("The specified element was found but is not compatible with PasswordBox");
     }
 }
开发者ID:MikeHanson,项目名称:WATKit,代码行数:11,代码来源:PasswordBox.cs

示例14: AddAutomationPropertyChangedEventHandler

        public static void AddAutomationPropertyChangedEventHandler(AutomationElement element, TreeScope scope, AutomationPropertyChangedEventHandler eventHandler, params AutomationProperty[] properties)
        {
            Utility.ValidateArgumentNonNull(element, "element");
            Utility.ValidateArgumentNonNull(eventHandler, "eventHandler");
            Utility.ValidateArgumentNonNull(properties, "properties");
            if (properties.Length == 0)
            {
                throw new ArgumentException("AtLeastOnePropertyMustBeSpecified");
            }
            int[] propertyIdArray = new int[properties.Length];
            for (int i = 0; i < properties.Length; ++i)
            {
                Utility.ValidateArgumentNonNull(properties[i], "properties");
                propertyIdArray[i] = properties[i].Id;
            }

            try
            {
                PropertyEventListener listener = new PropertyEventListener(AutomationElement.StructureChangedEvent, element, eventHandler);
                Factory.AddPropertyChangedEventHandler(
                    element.NativeElement,
                    (UIAutomationClient.TreeScope)scope,
                    CacheRequest.CurrentNativeCacheRequest,
                    listener,
                    propertyIdArray);
                ClientEventList.Add(listener);
            }
            catch (System.Runtime.InteropServices.COMException e)
            {
                Exception newEx; if (Utility.ConvertException(e, out newEx)) { throw newEx; } else { throw; }
            }
        }
开发者ID:jeffras,项目名称:uiverify,代码行数:32,代码来源:Automation.cs

示例15: Header

 public Header(AutomationElement element) : base(element) {
     AutomationElementCollection headerItems = FindAllByControlType(ControlType.HeaderItem);
     for (int i = 0; i < headerItems.Count; i++) {
         string colName = headerItems[i].GetCurrentPropertyValue(AutomationElement.NameProperty) as string;
         if (colName != null && !_columns.ContainsKey(colName)) _columns[colName] = i;
     }            
 }
开发者ID:sramos30,项目名称:ntvsiot,代码行数:7,代码来源:Header.cs


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