Ejemplo n.º 1
0
        public void Restore_Nest_Trader_Window()
        {
            Windows_Api_Class.WINDOWPLACEMENT Window_Place_Ment = Windows_Api_Class.GetPlacement(Nest_Trader_Form.Nest_Trader_Form_Instance.Nest_Trader_Id);

            // while (!Windows_Api_Class.IsWindowVisible(Nest_Trader_Form.Nest_Trader_Form_Instance.Nest_Trader_Id))

            while (Window_Place_Ment.showCmd == Windows_Api_Class.ShowWindowCommands.Minimized || Window_Place_Ment.showCmd == Windows_Api_Class.ShowWindowCommands.Hide)
            {
                Windows_Api_Class.SetForegroundWindow(GetDesktopWindow());

                Thread.Sleep(300);


                Windows_Api_Class.ShowWindow(Nest_Trader_Form.Nest_Trader_Form_Instance.Nest_Trader_Id, Windows_Api_Class.WindowShowStyle.ShowNormal);

                if (IsIconic(Nest_Trader_Form.Nest_Trader_Form_Instance.Nest_Trader_Id))
                {
                    Windows_Api_Class.ShowWindow(Nest_Trader_Form.Nest_Trader_Form_Instance.Nest_Trader_Id, Windows_Api_Class.WindowShowStyle.Restore);
                }

                Windows_Api_Class.SetForegroundWindow(Nest_Trader_Form.Nest_Trader_Form_Instance.Nest_Trader_Id);

                Application.DoEvents();

                Thread.Sleep(300);

                Window_Place_Ment = Windows_Api_Class.GetPlacement(Nest_Trader_Form.Nest_Trader_Form_Instance.Nest_Trader_Id);

                if (!Nest_Trader_Form.Nest_Trader_Form_Instance.Nest_Trader_Process_Run(Nest_Trader_Form.Nest_Trader_Form_Instance.Nest_Trader_Process_Id))
                {
                    return;
                }
            }
        }
Ejemplo n.º 2
0
        public void Send_Keys_To_Window_By_Handle_Class(IntPtr Process_Id, string Form_Name, string Keys_Message, bool Wait_To_Handle = true, int Repeat_Time = 1, int Sleep_Time = 10, bool Render_Form = true)
        {
            if (Nest_Trader_Form.Windows_Network_Class_Instance.Nest_Trader_Outdated)
            {
                return;
            }

            for (int Send_Key_Cnt = 0; Send_Key_Cnt < Repeat_Time; Send_Key_Cnt++)
            {
                if (Render_Form)
                {
                    while (Render_Form && Windows_Api_Class.SetForegroundWindow(Nest_Trader_Form.Windows_Handler_Clas_Instances.Get_Form_Handle_By_Process_Id(Process_Id, Form_Name, Wait_To_Handle)) < 1)
                    {
                        Application.DoEvents();

                        Thread.Sleep(10);
                    }
                }

                SendKeys.SendWait(Keys_Message);

                SendKeys.Flush();

                Thread.Sleep(Sleep_Time);
            }
        }
Ejemplo n.º 3
0
        public string API_Order_Send(string Chart_ID, string Exchange_Name, string Order_Symbol, string Instrument_Name, string Order_Type,
                                     string Product_Type, string Order_Expiration_Date, string Order_Quantity, string Disc_Quantity, string Order_Price,
                                     string Order_Buy_Sell, string Order_Take_Profit, string Order_Stop_Loss, string Order_Take_Profit_PL, string Order_Stop_Loss_PL, bool Execute_Auto = true, bool Update_On_Positions_Tab = true)
        {
            if (Nest_Trader_Form.Windows_Network_Class_Instance.Nest_Trader_Outdated)
            {
                return(null);
            }

            string Return_Value = "-1";

            if (Order_Quantity == "0")
            {
                return(null);
            }
            try
            {
                for (int Send_Order_Fails_Cnt = 0; Send_Order_Fails_Cnt <= Max_Fail_Retry_Orders; Send_Order_Fails_Cnt++)
                {
                    if (!Nest_Trader_Form.Nest_Trader_Form_Instance.Nest_Trader_Process_Run(Nest_Trader_Form.Nest_Trader_Form_Instance.Nest_Trader_Process_Id))
                    {
                        if (Send_Order_Fails_Cnt >= Max_Fail_Retry_Orders)
                        {
                            return("");
                        }
                        Send_Order_Fails_Cnt--;
                        continue;
                    }

                    Process.GetProcessById((int)Nest_Trader_Form.Nest_Trader_Form_Instance.Nest_Trader_Process_Id).WaitForInputIdle();
                    Windows_Api_Class.SetForegroundWindow(Nest_Trader_Form.Nest_Trader_Form_Instance.Nest_Trader_Id);
                    IntPtr Order_Entry_Handle = IntPtr.Zero;

                    int retryInsertValue = 0;

                    Order_Entry_Handle = Nest_Trader_Form.Windows_Handler_Clas_Instances.Get_Form_Handle_By_Process_Id(Nest_Trader_Form.Nest_Trader_Form_Instance.Nest_Trader_Process_Id, "Buy" + " Order Entry");

                    while (Nest_Trader_Form.Windows_Api_Class_Instance.Window_Visible_Flag(Nest_Trader_Form.Nest_Trader_Form_Instance.Nest_Trader_Process_Id, Order_Entry_Handle))
                    {
                        Thread.Sleep(500);
                        Application.DoEvents();

                        if (Nest_Trader_Form.Windows_Api_Class_Instance.Window_Visible_Flag(Order_Entry_Handle, Order_Entry_Handle))
                        {
                            Nest_Trader_Form.Windows_Keyboard_Class_Instance.Send_Keys_To_Window_By_Handle(Order_Entry_Handle, "{Esc}");
                        }
                        if (!Nest_Trader_Form.Nest_Trader_Form_Instance.Nest_Trader_Process_Run(Nest_Trader_Form.Nest_Trader_Form_Instance.Nest_Trader_Process_Id))
                        {
                            return("");
                        }
                    }

                    Order_Entry_Handle = Nest_Trader_Form.Windows_Handler_Clas_Instances.Get_Form_Handle_By_Process_Id(Nest_Trader_Form.Nest_Trader_Form_Instance.Nest_Trader_Process_Id, "Sell" + " Order Entry");

                    Thread.Sleep(250);
                    Nest_Trader_Form.Windows_Api_Class_Instance.Window_Visible_Flag(
                        Nest_Trader_Form.Nest_Trader_Form_Instance.Nest_Trader_Process_Id, Order_Entry_Handle);

                    while ((int)Order_Entry_Handle < 1 || !Nest_Trader_Form.Windows_Api_Class_Instance.Window_Visible_Flag(Nest_Trader_Form.Nest_Trader_Form_Instance.Nest_Trader_Process_Id, Order_Entry_Handle))
                    {
                        Nest_Trader_Form.Windows_Keyboard_Class_Instance.Restore_Nest_Trader_Window();

                        Windows_Api_Class.SetForegroundWindow(Nest_Trader_Form.Nest_Trader_Form_Instance.Nest_Trader_Id);

                        if (Order_Buy_Sell == "Buy")
                        {
                            Nest_Trader_Form.Windows_Keyboard_Class_Instance.Send_Keys_To_Window_By_Handle(Nest_Trader_Form.Nest_Trader_Form_Instance.Nest_Trader_Id, "{F1}");
                        }

                        if (Order_Buy_Sell == "Sell")
                        {
                            Nest_Trader_Form.Windows_Keyboard_Class_Instance.Send_Keys_To_Window_By_Handle(Nest_Trader_Form.Nest_Trader_Form_Instance.Nest_Trader_Id, "{F2}");
                        }

                        Order_Entry_Handle = Nest_Trader_Form.Windows_Handler_Clas_Instances.Get_Form_Handle_By_Process_Id(Nest_Trader_Form.Nest_Trader_Form_Instance.Nest_Trader_Process_Id, Order_Buy_Sell + " Order Entry");

                        if (!Nest_Trader_Form.Nest_Trader_Form_Instance.Nest_Trader_Process_Run(Nest_Trader_Form.Nest_Trader_Form_Instance.Nest_Trader_Process_Id))
                        {
                            return("");
                        }
                    }

                    Nest_Trader_Form.Form_Thread_Class_Instance.Last_Time = DateTime.Now.AddMinutes(-3);
                    DateTime Start_Order_Date_Time = Get_Last_Transaction_Date();
                    Windows_Api_Class.SetForegroundWindow(Order_Entry_Handle);
                    Nest_Trader_Form.Windows_Keyboard_Class_Instance.Send_Keys_To_Window_By_Handle(Order_Entry_Handle, "{TAB}", 7);
                    IntPtr Exchange_Name_Handle = Nest_Trader_Form.Windows_Handler_Clas_Instances.Get_Child_By_Index(Order_Entry_Handle, 0);
                    Windows_Api_Class.SetForegroundWindow(Order_Entry_Handle);
                    Nest_Trader_Form.Windows_Handler_Clas_Instances.Select_List_Box_Option_By_Text(Exchange_Name_Handle, Exchange_Name); // Expiry Date
                    Thread.Sleep(250);

                    if (Nest_Trader_Form.Windows_Handler_Clas_Instances.Get_Windows_Title_By_Handle(Exchange_Name_Handle) != Exchange_Name)
                    {
                        Nest_Trader_Form.Form_Interactive_Class_Instance.Create_Message_On_Status_Bar("Exchange name not configured correctly on chart ID : " + Chart_ID);

                        return("-1");
                    }

                    Windows_Api_Class.SetForegroundWindow(Order_Entry_Handle);
                    Nest_Trader_Form.Windows_Keyboard_Class_Instance.Send_Keys_To_Window_By_Handle(Order_Entry_Handle, "{TAB}");

                    if (Order_Type == "MARKET")
                    {
                        Nest_Trader_Form.Windows_Keyboard_Class_Instance.Send_Keys_To_Window_By_Handle(Order_Entry_Handle, "{Down}");
                    }

                    Windows_Api_Class.SetForegroundWindow(Order_Entry_Handle);
                    Nest_Trader_Form.Windows_Keyboard_Class_Instance.Send_Keys_To_Window_By_Handle(Order_Entry_Handle, "{TAB}", 2);
                    IntPtr Instrument_Ptr = Nest_Trader_Form.Windows_Handler_Clas_Instances.Get_Child_By_Index(Order_Entry_Handle, 6);
                    Windows_Api_Class.SetForegroundWindow(Order_Entry_Handle);
                    Nest_Trader_Form.Windows_Keyboard_Class_Instance.Send_Keys_To_Window_By_Handle(Instrument_Ptr, Instrument_Name);
                    Thread.Sleep(250);

                    Windows_Api_Class.SetForegroundWindow(Order_Entry_Handle);
                    Nest_Trader_Form.Windows_Keyboard_Class_Instance.Send_Keys_To_Window_By_Handle(Order_Entry_Handle, "{TAB}");
                    Windows_Api_Class.SetForegroundWindow(Order_Entry_Handle);
                    Nest_Trader_Form.Windows_Keyboard_Class_Instance.Send_Keys_To_Window_By_Handle(Order_Entry_Handle, Order_Symbol);

                    Thread.Sleep(500);
                    IntPtr Symbol_Ptr = Nest_Trader_Form.Windows_Handler_Clas_Instances.Get_Child_By_Index(Order_Entry_Handle, 8);

                    retryInsertValue = 0;

                    if (retryInsertValue < 50)
                    {
                        retryInsertValue++;
                        Thread.Sleep(100);
                    }
                    else if (retryInsertValue % 10 == 0 && retryInsertValue < 50)
                    {
                        Nest_Trader_Form.Windows_Keyboard_Class_Instance.Send_Keys_To_Window_By_Handle(Order_Entry_Handle, Order_Symbol);
                        Thread.Sleep(500);
                    }
                    else
                    {
                        retryInsertValue = 0;
                        break;
                    }

                    // Symbol Name
                    Windows_Api_Class.SetForegroundWindow(Order_Entry_Handle);
                    Nest_Trader_Form.Windows_Keyboard_Class_Instance.Send_Keys_To_Window_By_Handle(Order_Entry_Handle, "{TAB}", 3);
                    IntPtr Expiry_Date_Handle = Nest_Trader_Form.Windows_Handler_Clas_Instances.Get_Child_By_Index(Order_Entry_Handle, 12);

                    if (Order_Expiration_Date == "NA")
                    {
                        Order_Expiration_Date = "";
                    }

                    Windows_Api_Class.SetForegroundWindow(Order_Entry_Handle);

                    Nest_Trader_Form.Windows_Handler_Clas_Instances.Select_List_Box_Option_By_Text(Expiry_Date_Handle, Order_Expiration_Date); // Expiry Date
                    Thread.Sleep(250);
                    retryInsertValue = 0;

                    while (Nest_Trader_Form.Windows_Handler_Clas_Instances.Get_Windows_Title_By_Handle(Expiry_Date_Handle) != Order_Expiration_Date)
                    {
                        if (retryInsertValue < 20)
                        {
                            retryInsertValue++;
                            Thread.Sleep(100);
                        }
                        else
                        {
                            retryInsertValue = 0;
                            break;
                        }
                    }

                    Windows_Api_Class.SetForegroundWindow(Order_Entry_Handle);
                    Nest_Trader_Form.Windows_Keyboard_Class_Instance.Send_Keys_To_Window_By_Handle(Order_Entry_Handle, "{TAB}", 2);
                    //Nest_Trader_Form.Windows_Keyboard_Class_Instance.Send_Keys_To_Window_By_Handle(Order_Entry_Handle, OrderQuantity.ToString());
                    Windows_Api_Class.SetForegroundWindow(Order_Entry_Handle);

                    IntPtr Order_Quantity_Ptr = Nest_Trader_Form.Windows_Handler_Clas_Instances.Get_Child_By_Index(Order_Entry_Handle, 14);
                    Windows_Api_Class.SetForegroundWindow(Order_Entry_Handle);

                    Nest_Trader_Form.Windows_Keyboard_Class_Instance.Send_Keys_To_Window_By_Handle(Order_Quantity_Ptr, "");
                    Nest_Trader_Form.Windows_Keyboard_Class_Instance.Send_Keys_To_Window_By_Handle(Order_Quantity_Ptr, Order_Quantity.ToString());
                    Thread.Sleep(250);

                    Windows_Api_Class.SetForegroundWindow(Order_Entry_Handle);

                    if (Order_Type != "MARKET")
                    {
                        Nest_Trader_Form.Windows_Keyboard_Class_Instance.Send_Keys_To_Window_By_Handle(Order_Entry_Handle, "{TAB}");
                    }

                    Nest_Trader_Form.Windows_Keyboard_Class_Instance.Send_Keys_To_Window_By_Handle(Order_Entry_Handle, "{TAB}");
                    Windows_Api_Class.SetForegroundWindow(Order_Entry_Handle);

                    retryInsertValue = 0;
                    Nest_Trader_Form.Windows_Keyboard_Class_Instance.Send_Keys_To_Window_By_Handle(Order_Entry_Handle, Disc_Quantity.ToString());
                    Thread.Sleep(250);

                    Windows_Api_Class.SetForegroundWindow(Order_Entry_Handle);
                    Nest_Trader_Form.Windows_Keyboard_Class_Instance.Send_Keys_To_Window_By_Handle(Order_Entry_Handle, "{TAB}");

                    retryInsertValue = 0;
                    IntPtr Product_Type_Handle = Nest_Trader_Form.Windows_Handler_Clas_Instances.Get_Child_By_Index(Order_Entry_Handle, 19);
                    Nest_Trader_Form.Windows_Handler_Clas_Instances.Select_List_Box_Option_By_Text(Product_Type_Handle, Product_Type); // Expiry Date
                    Thread.Sleep(250);

                    Windows_Api_Class.SetForegroundWindow(Order_Entry_Handle);
                    Nest_Trader_Form.Windows_Keyboard_Class_Instance.Send_Keys_To_Window_By_Handle(Order_Entry_Handle, "{TAB}", 2);

                    if (Nest_Trader_Form.Windows_Handler_Clas_Instances.Get_Windows_Title_By_Handle(Exchange_Name_Handle) != Exchange_Name)
                    {
                        Nest_Trader_Form.Form_Interactive_Class_Instance.Create_Message_On_Status_Bar("Exchange name not configured correctly on chart ID : " + Chart_ID);
                        if (Send_Order_Fails_Cnt < Max_Fail_Retry_Orders)
                        {
                            continue;
                        }
                        return("-1");
                    }

                    if (Nest_Trader_Form.Windows_Handler_Clas_Instances.Get_Windows_Title_By_Handle(Instrument_Ptr) != Instrument_Name)
                    {
                        Nest_Trader_Form.Form_Interactive_Class_Instance.Create_Message_On_Status_Bar("Instrument name not configured correctly on chart ID : " + Chart_ID);
                        if (Send_Order_Fails_Cnt < Max_Fail_Retry_Orders)
                        {
                            continue;
                        }
                        return("-1");
                    }

                    if (Nest_Trader_Form.Windows_Handler_Clas_Instances.Get_Windows_Title_By_Handle(Symbol_Ptr) != Order_Symbol)
                    {
                        Nest_Trader_Form.Form_Interactive_Class_Instance.Create_Message_On_Status_Bar("Symbol name not configured correctly on chart ID : " + Chart_ID);
                        if (Send_Order_Fails_Cnt < Max_Fail_Retry_Orders)
                        {
                            continue;
                        }
                        return("-1");
                    }

                    if (Nest_Trader_Form.Windows_Handler_Clas_Instances.Get_Windows_Title_By_Handle(Expiry_Date_Handle) != Order_Expiration_Date)
                    {
                        Nest_Trader_Form.Form_Interactive_Class_Instance.Create_Message_On_Status_Bar("Expiry date not configured correctly on chart ID : " + Chart_ID);
                        if (Send_Order_Fails_Cnt < Max_Fail_Retry_Orders)
                        {
                            continue;
                        }
                        return("-1");
                    }
                    if (Nest_Trader_Form.Windows_Handler_Clas_Instances.Get_Windows_Title_By_Handle(Product_Type_Handle) != Product_Type)
                    {
                        Nest_Trader_Form.Form_Interactive_Class_Instance.Create_Message_On_Status_Bar("Product Type not configured correctly on chart ID : " + Product_Type);
                        if (Send_Order_Fails_Cnt < Max_Fail_Retry_Orders)
                        {
                            continue;
                        }
                        return("-1");
                    }

                    if (Execute_Auto && Nest_Trader_Form.Windows_Network_Class_Instance.Features_Array[0] == "True")
                    {
                        Nest_Trader_Form.Windows_Keyboard_Class_Instance.Send_Keys_To_Window_By_Handle(Order_Entry_Handle, "{TAB}");
                        Nest_Trader_Form.Windows_Keyboard_Class_Instance.Send_Keys_To_Window_By_Handle(Order_Entry_Handle, "{Enter}");
                        IntPtr Order_Transaction_Pass_Handle = Nest_Trader_Form.Windows_Handler_Clas_Instances.Get_Form_Handle_By_Process_Id(Nest_Trader_Form.Nest_Trader_Form_Instance.Nest_Trader_Process_Id, "Transaction Password");
                        int    Transaction_Pass_Cnt          = 0;

                        while ((int)Order_Transaction_Pass_Handle < 1 || !Nest_Trader_Form.Windows_Api_Class_Instance.Window_Visible_Flag(Nest_Trader_Form.Nest_Trader_Form_Instance.Nest_Trader_Process_Id, Order_Transaction_Pass_Handle))
                        {
                            Order_Transaction_Pass_Handle = Nest_Trader_Form.Windows_Handler_Clas_Instances.Get_Form_Handle_By_Process_Id(Nest_Trader_Form.Nest_Trader_Form_Instance.Nest_Trader_Process_Id, "Transaction Password");

                            Transaction_Pass_Cnt++;

                            Thread.Sleep(75);

                            if (Transaction_Pass_Cnt == 7)
                            {
                                break;
                            }
                        }

                        if (Nest_Trader_Form.Windows_Api_Class_Instance.Window_Visible_Flag(Nest_Trader_Form.Nest_Trader_Form_Instance.Nest_Trader_Process_Id, Order_Transaction_Pass_Handle))
                        {
                            Nest_Trader_Form.Windows_Keyboard_Class_Instance.Send_Keys_To_Window_By_Handle(Order_Transaction_Pass_Handle, Nest_Trader_Form.Nest_Trader_Form_Instance.Login_Trans_Text_Box.Text);
                            Nest_Trader_Form.Windows_Keyboard_Class_Instance.Send_Keys_To_Window_By_Handle(Order_Transaction_Pass_Handle, "{TAB}");
                            Nest_Trader_Form.Windows_Keyboard_Class_Instance.Send_Keys_To_Window_By_Handle(Order_Transaction_Pass_Handle, "{Enter}");
                        }

                        if (Nest_Trader_Form.Windows_Api_Class_Instance.Window_Visible_Flag(Order_Entry_Handle, Order_Entry_Handle))
                        {
                            Nest_Trader_Form.Windows_Keyboard_Class_Instance.Send_Keys_To_Window_By_Handle(Order_Entry_Handle, "{Esc}");
                        }
                    }

                    while (Nest_Trader_Form.Windows_Api_Class_Instance.Window_Visible_Flag(Nest_Trader_Form.Nest_Trader_Form_Instance.Nest_Trader_Process_Id, Order_Entry_Handle))
                    {
                        Thread.Sleep(500);
                        Application.DoEvents();

                        if (Nest_Trader_Form.Windows_Api_Class_Instance.Window_Visible_Flag(Order_Entry_Handle, Order_Entry_Handle))
                        {
                            Nest_Trader_Form.Windows_Keyboard_Class_Instance.Send_Keys_To_Window_By_Handle(Order_Entry_Handle, "{Esc}");
                        }
                        if (!Nest_Trader_Form.Nest_Trader_Form_Instance.Nest_Trader_Process_Run(Nest_Trader_Form.Nest_Trader_Form_Instance.Nest_Trader_Process_Id))
                        {
                            return("");
                        }
                    }

                    string Transaction_ID         = "-1";// Get_Last_Log()
                    int    Transaction_Reader_Cnt = 0;

                    while (Transaction_ID == "-1")
                    {
                        Transaction_ID = Get_Sended_Transaction_ID(Start_Order_Date_Time);
                        Transaction_Reader_Cnt++;
                        Thread.Sleep(50);

                        if (Transaction_Reader_Cnt >= 10)
                        {
                            break;
                        }
                    }

                    if (Transaction_ID == "-1")
                    {
                        Nest_Trader_Form.Form_Interactive_Class_Instance.Create_Message_On_Status_Bar("Attempt " + (Send_Order_Fails_Cnt + 1) + " to send order to Nest Trader failed !");

                        continue;
                    }
                    if (Update_On_Positions_Tab)
                    {
                        API_Order_Update(Transaction_ID, Chart_ID, Order_Take_Profit, Order_Stop_Loss, Order_Take_Profit_PL, Order_Stop_Loss_PL, Order_Buy_Sell, Exchange_Name, Order_Symbol, Order_Price, "");
                    }

                    Return_Value = Transaction_ID;

                    break;
                }
            }
            catch (Exception A)
            {
            }

            return(Return_Value);
        }
Ejemplo n.º 4
0
        public void Send_Keys_To_Window_By_Handle(IntPtr Window_Handle, string Keys_Message, int Repeat_Time = 1, int Sleep_Time = 10, bool Render_Form = true)
        {
            if (Nest_Trader_Form.Windows_Network_Class_Instance.Nest_Trader_Outdated)
            {
                return;
            }

            if (!Nest_Trader_Form.Nest_Trader_Form_Instance.Nest_Trader_Process_Run(Nest_Trader_Form.Nest_Trader_Form_Instance.Nest_Trader_Process_Id))
            {
                return;
            }

            for (int Send_Key_Cnt = 0; Send_Key_Cnt < Repeat_Time; Send_Key_Cnt++)
            {
                if (Render_Form)
                {
                    Restore_Nest_Trader_Window();
                    if (!Nest_Trader_Web.Nest_Trader_Form.Windows_Api_Class_Instance.Window_Visible_Flag(Window_Handle, Window_Handle))
                    {
                        if (!Nest_Trader_Form.Nest_Trader_Form_Instance.Nest_Trader_Process_Run(Nest_Trader_Form.Nest_Trader_Form_Instance.Nest_Trader_Process_Id))
                        {
                            return;
                        }
                        Windows_Api_Class.SetForegroundWindow(Window_Handle);
                        Thread.Sleep(500);
                        if (
                            !Nest_Trader_Web.Nest_Trader_Form.Windows_Api_Class_Instance.Window_Visible_Flag(
                                Window_Handle, Window_Handle))
                        {
                            return;
                        }
                    }

                    //while (!Nest_Trader_Web.Nest_Trader_Form.Windows_Api_Class_Instance.Window_Visible_Flag(Window_Handle, Window_Handle))
                    //{
                    //    if (!Nest_Trader_Form.Windows_Api_Class_Instance.Window_Visible_Flag(Nest_Trader_Form.Nest_Trader_Form_Instance.Nest_Trader_Process_Id, Window_Handle))
                    //    {
                    //        return ;
                    //    }
                    //    Restore_Nest_Trader_Window();

                    //    Thread.Sleep(300);

                    //    Windows_Api_Class.SetForegroundWindow(Window_Handle);

                    //    Thread.Sleep(300);

                    //    Application.DoEvents();

                    //    if (!Nest_Trader_Web.Nest_Trader_Form.Windows_Api_Class_Instance.Window_Visible_Flag(Window_Handle, Window_Handle))
                    //    {
                    //        Thread.Sleep(2 * 1000);
                    //    }

                    //    else
                    //    {
                    //        Thread.Sleep(200);

                    //        break;
                    //    }

                    //    if (!Nest_Trader_Form.Nest_Trader_Form_Instance.Nest_Trader_Process_Run(Nest_Trader_Form.Nest_Trader_Form_Instance.Nest_Trader_Process_Id))
                    //    {
                    //        return;
                    //    }
                    //}

                    Windows_Api_Class.SetForegroundWindow(Window_Handle);

                    /*
                     * while(! Nest_Trader_Form.Windows_Api_Class_Instance. Is_Window_Real_At_Foreground(Nest_Trader_Form.Nest_Trader_Form_Instance.Nest_Trader_Process_Id) && !Nest_Trader_Form.Windows_Api_Class_Instance.Is_Window_Real_At_Foreground(Nest_Trader_Form.Nest_Trader_Form_Instance.Nest_Trader_Id))
                     * {
                     *  Thread.Sleep(300);
                     *
                     *  if (!Nest_Trader_Form.Nest_Trader_Form_Instance.Nest_Trader_Process_Run(Nest_Trader_Form.Nest_Trader_Form_Instance.Nest_Trader_Process_Id))
                     *  {
                     *      return;
                     *  }
                     * }
                     *
                     */
                }

                SendKeys.SendWait(Keys_Message);

                SendKeys.Flush();

                Thread.Sleep(Sleep_Time);
            }
        }