示例#1
0
文件: AuTest.cs 项目: Keyabob/MMG
        public void GetControls()
        {
            //window = AutomationElement.FromHandle(new IntPtr(window.Current.NativeWindowHandle));
            var autoIds = new string[] {
                "12005",
                "12006",
                "12007",
                "2010"};
            var types = new TradeContorlTypes[] {
                TradeContorlTypes.BuyCode,
                TradeContorlTypes.BuyMoney,
                TradeContorlTypes.BuyAmount,
                TradeContorlTypes.BuyButton };

            PropertyCondition propertyCondition = null;
            for (var i = 0; i < autoIds.Length; i++)
            {
                propertyCondition = new PropertyCondition(AutomationElement.AutomationIdProperty, autoIds[i]);
                var control = window.FindFirst(TreeScope.Subtree, propertyCondition);
                if (control != null)
                {
                    TradeControls.Instance().AddControl(types[i], control);
                }
            }
        }
示例#2
0
 public AutomationElement GetControl(TradeContorlTypes type)
 {
     return this.handles[type];
 }
示例#3
0
 public void AddControl(TradeContorlTypes type, AutomationElement element)
 {
     Debug.Assert(type != null, "type为空");
     Debug.Assert(element != null, "界面元素为空");
     this.handles.Add(type, element);
 }