/// <summary> /// 获取下单按钮的UIELement /// </summary> /// <param name="_type">"买入下单" or "卖出下单"</param> static void GetZTOrder(string _type) { var uielement = new iAutomationElement(); var elementlist = uielement.enumRoot(); elementlist = uielement.FindByName("中投证券", elementlist); elementlist = uielement.enumNode(elementlist[0]); if (elementlist.Count > 1) { foreach (AutomationElement item in elementlist) { var list = uielement.enumDescendants(item, _type); if (list.Count > 0) { if (_type == "买入下单") { ZT_BuyOrder = list[0]; } else if (_type == "卖出下单") { ZT_SaleOrder = list[0]; } //uielement.WriteTextBox(elementlist[0], "\b\b\b\b\b\b"); //uielement.WriteTextBox(elementlist[0], "000005"); } } } }
/// <summary> /// 获取NumBox的UIElement /// </summary> /// <param name="_type">"买入下单" or "卖出下单"</param> static void GetNumboxElement(string _type) { var uielement = new iAutomationElement(); var elementlist = uielement.enumRoot(); elementlist = uielement.FindByName("中投证券", elementlist); elementlist = uielement.enumNode(elementlist[0]); if (elementlist.Count > 1) { foreach (AutomationElement item in elementlist) { var list = uielement.enumDescendants(item, _type); if (list.Count > 0) { buyWindowsElement = TreeWalker.RawViewWalker.GetParent(list[0]); elementlist = uielement.enumNode(buyWindowsElement); elementlist = uielement.FindByClassName("Edit", elementlist); foreach (var i in elementlist) { if (i.Current.Name.ToString() == "" || i.Current.Name.ToString() == string.Empty) { if (_type == "买入下单") { ZT_BuyNum = i; } else if (_type == "卖出下单") { ZT_SaleNum = i; } } } } } } }
/// <summary> /// 获取证券代码TextBoxUIElement /// </summary> /// <param name="_type">"买入下单" or "卖出下单"</param> static void GetZTSecodeElement(string _type) { var uielement = new iAutomationElement(); var elementlist = uielement.enumRoot(); elementlist = uielement.FindByName("中投证券", elementlist); elementlist = uielement.enumNode(elementlist[0]); if (elementlist.Count > 1) { foreach (AutomationElement item in elementlist) { var list = uielement.enumDescendants(item, _type); if (list.Count > 0) { buyWindowsElement = TreeWalker.RawViewWalker.GetParent(list[0]); elementlist = uielement.enumNode(buyWindowsElement); elementlist = uielement.FindByClassName("AfxWnd42", elementlist); if (_type == "买入下单") { ZT_BuySecuritiesCode = elementlist[0]; } else if (_type == "卖出下单") { ZT_SaleSecuritiesCode = elementlist[0]; } //uielement.WriteTextBox(elementlist[0], "\b\b\b\b\b\b"); //uielement.WriteTextBox(elementlist[0], "000005"); } } } }
/// <summary> /// 中投证券买入or点击 /// </summary> /// <param name="_type">"买入"or"卖出"</param> static void GetZT_OrderButtonElement(string _type) { var uielement = new iAutomationElement(); var elementlist = uielement.enumRoot(); elementlist = uielement.FindByName("中投证券", elementlist); elementlist = uielement.enumNode(elementlist[0]); if (elementlist.Count > 1) { foreach (AutomationElement item in elementlist) { var list = uielement.enumDescendants(item, "锁定"); if (list.Count > 0) { buyWindowsElement = TreeWalker.RawViewWalker.GetParent(list[0]); elementlist = uielement.enumNode(buyWindowsElement); elementlist = uielement.FindByName(_type, elementlist); if (_type == "买入") { ZT_BuyButtonElement = elementlist[0]; } else if (_type == "卖出") { ZT_SaleButtonElement = elementlist[0]; } //uielement.InvokeButton(elementlist[0]); } } } }
/// <summary> /// 获取持仓单UIElement /// 调用前需要点击买入or卖出按钮切换界面 /// </summary> /// <param name="_type" >"买入下单"or "卖出下单"</param> static void GetZTViewListElement(string _type) { var uielement = new iAutomationElement(); var elementlist = uielement.enumRoot(); elementlist = uielement.FindByName("中投证券", elementlist); elementlist = uielement.enumNode(elementlist[0]); if (elementlist.Count > 1) { foreach (AutomationElement item in elementlist) { var list = uielement.enumDescendants(item, _type); if (list.Count > 0) { buyWindowsElement = TreeWalker.RawViewWalker.GetParent(list[0]); elementlist = uielement.enumNode(buyWindowsElement); elementlist = uielement.FindByClassName("SysListView32", elementlist); if (_type == "买入下单") { ZT_BuyListView = elementlist[0]; } else if (_type == "卖出下单") { ZT_SaleListView = elementlist[0]; } ZT_DataList = uielement.GetViewList(elementlist[0], 19); } } } }
static void Clickconfirm() { var uielement = new iAutomationElement(); var elementlist = uielement.enumRoot(); elementlist = uielement.FindByName("中投证券", elementlist); //uielement.ESCclick(elementlist[0]); elementlist = uielement.enumNode(elementlist[0]); if (elementlist.Count > 1) { foreach (AutomationElement item in elementlist) { var list = uielement.enumDescendants(item, "提示"); if (list.Count > 0) { Console.WriteLine("ture"); buyWindowsElement = TreeWalker.RawViewWalker.GetParent(list[0]); elementlist = uielement.enumNode(buyWindowsElement); elementlist = uielement.FindByName("确认", elementlist); var orderClick = new iAutomationElement(); orderClick.InvokeButton(elementlist[0]); //return; } } } }
/// <summary> /// 获取确认交易按钮 UIElement /// </summary> /// <param name="_type">"买入确认" or "卖出确认"</param> static void GetConfirm(string _type) { try { var uielement = new iAutomationElement(); var elementlist = uielement.enumRoot(); elementlist = uielement.FindByName("中投证券", elementlist); elementlist = uielement.enumNode(elementlist[0]); if (elementlist.Count > 1) { foreach (AutomationElement item in elementlist) { var list = uielement.enumDescendants(item, _type); if (list.Count > 0) { if (_type == "买入确认") { ZT_BuyConfirm = list[0]; } else if (_type == "卖出确认") { ZT_SaleConfirm = list[0]; } } } } } catch { return; } }
/// <summary> /// 获取 /// </summary> static void GetZT_OutPutSuessElement() { var uielement = new iAutomationElement(); var elementlist = uielement.enumRoot(); elementlist = uielement.FindByName("中投证券", elementlist); elementlist = uielement.enumNode(elementlist[0]); if (elementlist.Count > 1) { foreach (AutomationElement item in elementlist) { var list = uielement.enumDescendants(item, "输出"); if (list.Count > 0) { buyWindowsElement = TreeWalker.RawViewWalker.GetParent(list[0]); elementlist = uielement.enumNode(buyWindowsElement); elementlist = uielement.FindByName("确 定", elementlist); ZT_OutputSuess = elementlist[0]; } } } }
/// <summary> /// 获取当前可用资金 /// </summary> static void GetCanUseMoney() { var uielement = new iAutomationElement(); var elementlist = uielement.enumRoot(); elementlist = uielement.FindByName("中投证券", elementlist); elementlist = uielement.enumNode(elementlist[0]); if (elementlist.Count > 1) { foreach (AutomationElement item in elementlist) { var list = uielement.enumDescendants(item, "买入下单"); if (list.Count > 0) { buyWindowsElement = TreeWalker.RawViewWalker.GetParent(list[0]); elementlist = uielement.enumNode(buyWindowsElement); elementlist = uielement.FindByClassName("Static", elementlist); ZT_CanUseMoney = elementlist[7]; } } } }
/// <summary> /// 获取输出AutomationElement /// </summary> static void GetZT_OutPutElement() { var uielement = new iAutomationElement(); var elementlist = uielement.enumRoot(); elementlist = uielement.FindByName("中投证券", elementlist); elementlist = uielement.enumNode(elementlist[0]); if (elementlist.Count > 1) { foreach (AutomationElement item in elementlist) { var list = uielement.enumDescendants(item, "修改成本"); if (list.Count > 0) { buyWindowsElement = TreeWalker.RawViewWalker.GetParent(list[0]); elementlist = uielement.enumNode(buyWindowsElement); elementlist = uielement.FindByName("输 出", elementlist); ZT_Output = elementlist[0]; //uielement.WriteTextBox(elementlist[0], "\b\b\b\b\b\b"); //uielement.WriteTextBox(elementlist[0], "000005"); } } } }
/// <summary> /// 获取持仓按钮 /// </summary> static void GetZT_PositionOrderButtonElement() { var uielement = new iAutomationElement(); var elementlist = uielement.enumRoot(); elementlist = uielement.FindByName("中投证券", elementlist); elementlist = uielement.enumNode(elementlist[0]); if (elementlist.Count > 1) { foreach (AutomationElement item in elementlist) { var list = uielement.enumDescendants(item, "锁定"); if (list.Count > 0) { buyWindowsElement = TreeWalker.RawViewWalker.GetParent(list[0]); elementlist = uielement.enumNode(buyWindowsElement); elementlist = uielement.FindByName("持仓", elementlist); ZT_PositionOrder = elementlist[0]; //uielement.InvokeButton(elementlist[0]); } } } }