private async void cmdStart(Programm pr)
 {
     await Task.Run(() =>
     {
         try
         {
             Process proccess = Process.Start(pr.pathProg, pr.attributs);
             if (processis.ContainsKey(pr.name))
             {
             }
             else
             {
                 processis.Add(pr.name, proccess);
             }
             setLog(TypeLog.Info, "запущена программа " + pr.name + " " + pr.pathProg + " с параметрами " + pr.attributs);
         }
         catch (Exception e) { setLog(TypeLog.Info, "запущена программа " + pr.name + " ошибка " + e.Message); }
     });
 }
Exemple #2
0
        private void filereaderConfig(string path)
        {
            using (StreamReader filestream = new StreamReader(path))
            {
                string line;
                while ((line = filestream.ReadLine()) != null)
                {
                    string[] commandsString    = line.Split('|');
                    string   name_command      = commandsString[0];
                    string   pathProg_command  = (commandsString.Length > 1) ? commandsString[1] : "";
                    string   attrib_command    = (commandsString.Length > 2) ? commandsString[2] : "";
                    int      startTime_command = (commandsString.Length > 3) ? Int32.Parse(commandsString[3]) : 0;
                    int      delayTime_command = (commandsString.Length > 4) ? Int32.Parse(commandsString[4]) : 0;

                    FlowLayoutPanel flow = new FlowLayoutPanel();
                    flow.FlowDirection = FlowDirection.LeftToRight;
                    flow.Width         = 730;
                    flow.Height        = 27;
                    TextBox textbox = new TextBox();    //Баланс
                    textbox.Text  = "";
                    textbox.Width = 200;
                    // labelm.Height = 27;
                    textbox.BackColor = Color.FromArgb(240, 230, 140);
                    textbox.Margin    = new Padding(1);
                    textbox.Font      = new Font("Times New Roman", 13, FontStyle.Regular);

                    TextBox textboxName = new TextBox();
                    textboxName.Text  = name_command;
                    textboxName.Width = 200;
                    // labelm.Height = 27;
                    textboxName.BackColor = Color.FromArgb(240, 230, 140);
                    textboxName.Margin    = new Padding(1);
                    textboxName.Font      = new Font("Times New Roman", 13, FontStyle.Regular);

                    Button button = new Button();
                    button.Margin = new Padding(0);
                    button.Height = 27;
                    button.Width  = 100;
                    button.Text   = "параметры";
                    button.Font   = new Font("Times New Roman", 13, FontStyle.Regular);
                    button.Name   = buttons.Count + "";
                    button.Click += Button_Click;


                    ProgressBar progressbar = new ProgressBar();
                    progressbar.Text  = "";
                    progressbar.Width = 170;
                    // labelm.Height = 27;
                    progressbar.BackColor = Color.FromArgb(240, 230, 140);
                    progressbar.Margin    = new Padding(1);
                    progressbar.Font      = new Font("Times New Roman", 13, FontStyle.Regular);
                    SendMessage(progressbar.Handle, 0x410, 3, 0);//yellow

                    Button buttonOffOn = new Button();
                    buttonOffOn.Width     = 50;
                    buttonOffOn.Margin    = new Padding(0, 0, 0, 0);
                    buttonOffOn.Text      = "WAIT";
                    buttonOffOn.BackColor = Color.Yellow;
                    buttonOffOn.Click    += ButtonOffOn_Click;
                    buttonOffOn.Name      = buttons.Count + " onoff";

                    flow.Controls.AddRange(new Control[] { textboxName, textbox, button, progressbar, buttonOffOn });
                    flowLayoutPanel1.Controls.Add(flow);
                    buttons.Add(button);
                    Programm pro = new Programm(name_command, pathProg_command, attrib_command, startTime_command, delayTime_command);
                    classBotTimer.listProgramm.Add(pro);
                    progressbarss.Add(progressbar);
                    checks.Add(buttonOffOn);
                    textboxess.Add(textbox);
                    textboxessName.Add(textboxName);
                }
            }
            classBotTimer.isBotWork = true;
            goBotTimer();
            startProgDeffTimer = DateTime.Now;
            timer1.Start();
        }
Exemple #3
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            int countProg = 0;

            for (int i = 0; i < progressbarss.Count; i++)
            {
                Programm pro      = classBotTimer.listProgramm[i];
                int      startPro = pro.timestart * 1000 * 60;                                              //промежуток времени когда запустится программа
                int      now      = (int)((TimeSpan)(DateTime.Now - startProgDeffTimer)).TotalMilliseconds; //промежуток от старта программы до сейчас

                int minus = startPro - now;
                if (minus < 0)
                {
                    minus = 0;
                }

                progressbarss[i].Text = "осталось " + minus + "секунд";
                if (pro.timerDelay * 1000 * 60 < minus)
                {
                    progressbarss[i].Maximum = startPro;
                    progressbarss[i].Value   = minus;
                }
                else
                {
                    progressbarss[i].Maximum = pro.timerDelay * 1000 * 60;
                    progressbarss[i].Value   = minus;
                }
                int hource = (int)(minus / (1000 * 60 * 60));
                int minut  = (int)((minus - (hource * 1000 * 60 * 60)) / (1000 * 60));
                int sec    = (int)((minus - (hource * 1000 * 60 * 60) - (minut * 1000 * 60)) / 1000);
                buttons[i].Text = hource + ":" + minut.ToString("00") + ":" + sec.ToString("00");
                if (classBotTimer.processis.ContainsKey(pro.name))
                {
                    buttons[i].BackColor = Color.FromArgb(124, 252, 0); //lite green
                                                                        // textboxessName[i].BackColor = Color.FromArgb(152, 251, 152);    //green
                                                                        // textboxess[i].BackColor = Color.FromArgb(152, 251, 152);   //green
                                                                        // SendMessage(progressbarss[i].Handle, 0x410, 1, 0);//green
                                                                        //  checks[i].BackColor = Color.Green;
                                                                        //  checks[i].Text = "ON";
                    countProg++;
                    Process proc = classBotTimer.processis[pro.name];
                    if (proc.HasExited)
                    {
                        classBotTimer.processis.Remove(pro.name);
                        doexitCode(proc.ExitCode, i);
                    }
                }
                else
                {
                    buttons[i].BackColor = Color.White; //white
                }
            }
            if (countProg > 0 && !isCat)
            {
                //запустить кота
                startCat();

                isCat = true;
            }
            if (countProg == 0 && isCat)
            {
                //остановить кота
                Process[] proc = Process.GetProcesses();
                foreach (Process process in proc)
                {
                    if (process.ProcessName == "mpv")
                    {
                        process.Kill();
                    }
                }

                isCat = false;
            }
        }