public void doRefresh() { form1Data = null; form2Data = null; Process[] processes = Process.GetProcesses(); comboBox1.Items.Clear(); comboBox2.Items.Clear(); foreach (Process process in processes) { //Get whatever attribute for process if (!string.IsNullOrEmpty(process.MainWindowTitle)) { comboBox1.DisplayMember = "MainWindowTitle"; comboBox2.DisplayMember = "MainWindowTitle"; comboBox1.Items.Add(process); comboBox2.Items.Add(process); } } }
public AutoWork(AutoFormData[] formList, int totalMiuntes) { _formList = formList; _totalSeconds = totalMiuntes * 60; _random = new Random(); }
private void Init() { form1Data = new AutoFormData(); form1Data.Title = nameForm1_tbx.Text; form1Data.TextKeyboard = textForm1_tbx.Text.Trim(); form1Data.MouseData = form1MousePos_tbx.Text.Trim(); var process = comboBox1.SelectedItem as Process; if (process != null) { form1Data.Pid = process.MainWindowHandle; form1Data.TimeRun = Convert.ToInt32(form1TimeRun_tbx.Text); form1Data.TimeMouseClick = Convert.ToInt32(form1TimeMouseClick_tbx.Text); form1Data.TimeWait = Convert.ToInt32(form1TimeWait_tbx.Text); form1Data.IsSendBackKey = form1_cbx.Checked; } //if (form1Data.Pid == IntPtr.Zero) //{ // MessageBox.Show("Form 1 not valid"); //} form2Data = new AutoFormData(); form2Data.Title = nameForm2_tbx.Text; form2Data.TextKeyboard = textForm2_tbx.Text; form2Data.MouseData = form2MousePos_tbx.Text; process = comboBox2.SelectedItem as Process; if (process != null) { form2Data.Pid = process.MainWindowHandle; form2Data.TimeRun = Convert.ToInt32(form2TimeRun_tbx.Text); form2Data.TimeMouseClick = Convert.ToInt32(form2TimeMouseClick_tbx.Text); form2Data.TimeWait = Convert.ToInt32(form2TimeWait_tbx.Text); form2Data.IsSendBackKey = form2_cbx.Checked; } //if (form2Data.Pid == IntPtr.Zero) //{ // MessageBox.Show("Form 2 not valid"); // return; //} }
private void start_btn_Click(object sender, EventArgs e) { Init(); if (_work != null && _work.IsRun) { _work.Stop(); } var arr = new AutoFormData[2] { form1Data, form2Data }; _work = new AutoWork(arr, Convert.ToInt32(totalTime_tbx.Text)); _work.Start(); }