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); } } }
public AutomationElement GetControl(TradeContorlTypes type) { return this.handles[type]; }
public void AddControl(TradeContorlTypes type, AutomationElement element) { Debug.Assert(type != null, "type为空"); Debug.Assert(element != null, "界面元素为空"); this.handles.Add(type, element); }