/// <summary> /// Assign all points in the queue to the ClickHelper and start the thread /// </summary> private void StartClickingButton_Click(object sender, EventArgs e) { m_clicking = true; if (IsValidNumericalInput(NumRepeatsTextBox.Text)) { int iterations = Convert.ToInt32(NumRepeatsTextBox.Text); List <Point> points = new List <Point>(); List <string> clickType = new List <string>(); List <int> times = new List <int>(); foreach (ListViewItem item in PositionsListView.Items) { //Add data in queued clicks to corresponding List collection int x = Convert.ToInt32(item.Text); //x coordinate int y = Convert.ToInt32(item.SubItems[1].Text); //y coordinate clickType.Add(item.SubItems[2].Text); //click type times.Add(Convert.ToInt32(item.SubItems[3].Text)); //sleep time points.Add(new Point(x, y)); } try { //Create a ClickHelper passing Lists of click information ClickThreadHelper helper = new ClickThreadHelper() { Points = points, ClickType = clickType, Iterations = iterations, Times = times }; //Create the thread passing the Run method ClickThread = new Thread(new ThreadStart(helper.Run)); //Start the thread, thus starting the clicks ClickThread.Start(); } catch (Exception exc) { MessageBox.Show(exc.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Number of repeats is not a valid positive integer", "Invalid Input", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// Assign all points in the queue to the ClickHelper and start the thread /// </summary> private void StartClickingButton_Click(object sender, EventArgs e) { if (IsValidNumericalInput(NumRepeatsTextBox.Text)) { int iterations = Convert.ToInt32(NumRepeatsTextBox.Text); List<Point> points = new List<Point>(); List<string> clickType = new List<string>(); List<int> times = new List<int>(); foreach (ListViewItem item in PositionsListView.Items) { //Add data in queued clicks to corresponding List collection int x = Convert.ToInt32(item.Text); //x coordinate int y = Convert.ToInt32(item.SubItems[1].Text); //y coordinate clickType.Add(item.SubItems[2].Text); //click type times.Add(Convert.ToInt32(item.SubItems[3].Text)); //sleep time points.Add(new Point(x, y)); } try { //Create a ClickHelper passing Lists of click information ClickThreadHelper helper = new ClickThreadHelper() { Points = points, ClickType = clickType, Iterations = iterations, Times = times }; //Create the thread passing the Run method ClickThread = new Thread(new ThreadStart(helper.Run)); //Start the thread, thus starting the clicks ClickThread.Start(); } catch (Exception exc) { MessageBox.Show(exc.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Number of repeats is not a valid positive integer", "Invalid Input", MessageBoxButtons.OK, MessageBoxIcon.Error); } }