/// <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> /// 获取下单按钮的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> /// 中投证券买入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> /// 获取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; } } } } } } }
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 /// 调用前需要点击买入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); } } } }
/// <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; } }
static void f(string _type) { var uielement = new iAutomationElement(); var elementlist = uielement.enumRoot(); elementlist = uielement.FindByName("中投证券", elementlist); elementlist = uielement.enumNode(elementlist[0]); foreach (var i in elementlist) { Console.WriteLine(i.Current.ClassName + " " + i.Current.Name); } //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]); // buyWindowsElement = TreeWalker.RawViewWalker.GetParent(buyWindowsElement); // elementlist = uielement.enumNode(buyWindowsElement); // } // } //} }
/// <summary> /// 更新持仓单信息 /// </summary> void UpdatePostion() { var click = new iAutomationElement(); if (ZT_PositionOrder != null) { click.InvokeButton(ZT_PositionOrder); GetZT_OutPutElement(); if (ZT_Output != null) { click.InvokeButton(ZT_Output); GetZT_OutPutSuessElement(); if (ZT_OutputSuess != null) { click.InvokeButton(ZT_OutputSuess); Thread.Sleep(500); var uielement = new iAutomationElement(); var elementlist = uielement.enumRoot(); elementlist = uielement.FindByClassName("Notepad", elementlist); uielement.CloseTextBook(elementlist[0]); var list = ReadText.Read(); foreach (var item in list) { string[] array = item.Split(new char[] { '|' }); var data = new DataItem(); data.data = array; if (!ZT_DataList.ContainsKey(array[0])) { ZT_DataList.Add(array[0], data); } else { //若标记为空更新全部数据 if (ZT_DataList[array[0]].data[18] == "") { ZT_DataList[array[0]] = data; } else { data.data[18] = "1"; ZT_DataList[array[0]] = data; } } } } } } }
/// <summary> /// 大智慧预警表读取 /// </summary> static void GetReadWaringListViewElement() { var uielement = new iAutomationElement(); var elemlentlist = uielement.enumRoot(); elemlentlist = uielement.FindByName("大智慧", elemlentlist); elemlentlist = uielement.enumNode(elemlentlist[0]); elemlentlist = uielement.FindByName("预警", elemlentlist); //foreach (AutomationElement item in elemlentlist) //{ // Console.WriteLine(item.Current.Name + "" + item.Current.ClassName); //} elemlentlist = uielement.enumNode(elemlentlist[0]); elemlentlist = uielement.FindByName("List2", elemlentlist); DZH_uiElement = elemlentlist[0]; DZH_DataList = uielement.GetViewList(elemlentlist[0],5); }
/// <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> /// 大智慧预警表读取 /// </summary> void GetReadWaringListViewElement() { var uielement = new iAutomationElement(); var elemlentlist = uielement.enumRoot(); elemlentlist = uielement.FindByName("大智慧", elemlentlist); if (elemlentlist.Count > 0) { elemlentlist = uielement.enumNode(elemlentlist[0]); elemlentlist = uielement.FindByName("预警", elemlentlist); if (elemlentlist.Count > 0) { elemlentlist = uielement.enumNode(elemlentlist[0]); elemlentlist = uielement.FindByName("List2", elemlentlist); if (elemlentlist.Count > 0) { DZH_uiElement = elemlentlist[0]; DZH_DataList = uielement.GetViewList(elemlentlist[0], 5); } else { output("预警列表加载失败"); return; } } else { output("预警列表未打开"); return; } } else { output("未找到大智慧句柄"); return; } }
/// <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]); } } } }