• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Automation.AutomationElement类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: GetAddInRibbonTabElement

        public static AutomationElement GetAddInRibbonTabElement(AutomationElement excelElement, ExcelAppWrapper app)
        {
            const string TheAddInTabControlName = "The AddIn";

            var ribbonTabs = UIAUtility.FindElementByNameWithTimeout(excelElement, "Ribbon Tabs", AddinTestUtility.RibbonButtonsBecomeActivatedTimeout,
                    TreeScope.Descendants);

            var deTab = UIAUtility.FindElementByNameWithTimeout(ribbonTabs, TheAddInTabControlName, TimeSpan.FromSeconds(5),
                    TreeScope.Descendants); //Note Descendants needed here only for excel 2007

            if (app.IsVersion2010OrAbove())
            {
                UIAUtility.SelectMenu(deTab);
            }
            else
            {
                UIAUtility.PressButton(deTab);
            }

            var lowerRibbon = UIAUtility.FindElementByNameWithTimeout(excelElement, "Lower Ribbon", AddinTestUtility.RibbonButtonsBecomeActivatedTimeout,
                    TreeScope.Descendants);

            return UIAUtility.FindElementByNameWithTimeout(lowerRibbon, TheAddInTabControlName, AddinTestUtility.RibbonButtonsBecomeActivatedTimeout,
                    TreeScope.Descendants); //Note Descendants needed here only for excel 2007
        }
开发者ID:brogersyh,项目名称:.NET-WindowsUI-AutomationElementsTest,代码行数:25,代码来源:AddinTestUtility.cs


示例17: Enqueue

        public static void Enqueue(
			AutomationElement elementToHighlight,
			int highlightersGeneration,
		    string highlighterData)
        {
            Highlighter highlighter = null;
            if (null != (elementToHighlight as AutomationElement)) {

                if (0 >= highlightersGeneration) {
                    HighlighterNumber++;
                } else {
                    HighlighterNumber = highlightersGeneration;
                }

                highlighter =
                    new Highlighter(
                        elementToHighlight.Current.BoundingRectangle.Height,
                        elementToHighlight.Current.BoundingRectangle.Width,
                        elementToHighlight.Current.BoundingRectangle.X,
                        elementToHighlight.Current.BoundingRectangle.Y,
                        elementToHighlight.Current.NativeWindowHandle,
                        (Highlighters)(HighlighterNumber % 10),
                        HighlighterNumber,
                        highlighterData);
                ExecutionPlan.Enqueue(highlighter);
            }
        }
开发者ID:krisdages,项目名称:STUPS,代码行数:27,代码来源:ExecutionPlan.cs


示例18: FindElementsByName

 // 指定したName属性に一致するAutomationElementをすべて返します
 private static IEnumerable<AutomationElement> FindElementsByName(AutomationElement rootElement, string name)
 {
     return rootElement.FindAll(
         TreeScope.Element | TreeScope.Descendants,
         new PropertyCondition(AutomationElement.NameProperty, name))
         .Cast<AutomationElement>();
 }
开发者ID:shigusa,项目名称:Senri,代码行数:8,代码来源:WindowsUIAutomationCommand.cs


示例19: GetIElementFromBase

 /// <summary>
 /// Get a new IElement from a base AutomationElement.
 /// </summary>
 /// <param name="ae">Base AutomationElement</param>
 /// <returns>An implementation of IElement.</returns>
 internal static IElement GetIElementFromBase(AutomationElement ae)
 {
     return GetIElementFromHandlers(
         Factories.ElementActionHandlerFactory.GetActionHandler(ae),
         Factories.ElementDescendantHandlerFactory.GetDescendantHandler(ae)
     );
 }
开发者ID:urbaneinnovation,项目名称:Ice,代码行数:12,代码来源:ElementFactory.cs


示例20: FindButtonsByName

 // 指定したName属性に一致するボタン要素をすべて返します
 private static IEnumerable<AutomationElement> FindButtonsByName(AutomationElement rootElement, string name)
 {
     const string BUTTON_CLASS_NAME = "Button";
     return from x in FindElementsByName(rootElement, name)
            where x.Current.ClassName == BUTTON_CLASS_NAME
            select x;
 }
开发者ID:shigusa,项目名称:Senri,代码行数:8,代码来源:WindowsUIAutomationCommand.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Automation.AutomationEvent类代码示例发布时间:2022-05-26
下一篇:
C# Windows.Window类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap