Beispiel #1
0
        private void btnPlay_Click(object sender, EventArgs e)
        {
            if (btnPlay.Text == "PLAY")
            {
                if (lv.Items.Count == 0)
                {
                    MessageBox.Show("No Rules Found", "Rules", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                // timer speed in ms
                timer_click.Interval = Convert.ToInt32(numDelay.Value);

                // reset counters
                foreach (ListViewItem ITM in lv.Items)
                {
                    Models.ClickInfo Cpf = (Models.ClickInfo)ITM.Tag;

                    Cpf.Counter = 0;

                    ITM.SubItems[2].Text = Cpf.Counter.ToString();
                }

                Application.DoEvents();

                bPlay   = true;
                DTStart = DateTime.Now;
            }
            else
            {
                bPlay = false;
            }
        }
Beispiel #2
0
        private void HandleAddList()
        {
            bool         bFoundDuplicate = false;
            ListViewItem LST;

            // Prevent accidentally Pressing Ctrl.
            if (!bPlay)
            {
                int iX = Control.MousePosition.X;
                int iY = Control.MousePosition.Y;

                Color cColor = GetPixelColor(iX, iY);

                foreach (ListViewItem ITM in lv.Items)
                {
                    bFoundDuplicate = MatchColor(cColor, ITM.SubItems[3].BackColor, tb_tolerance.Value);
                }

                if (!bFoundDuplicate && lv.Items.Count < 10)
                {
                    string[] arr = new string[8];

                    arr[0] = ColorTranslator.ToHtml(cColor).ToString();
                    arr[1] = iX.ToString() + "," + iY.ToString();
                    arr[2] = "0";
                    arr[3] = "-";

                    Models.ClickInfo CPf = new Models.ClickInfo
                    {
                        Color   = cColor,
                        Click_X = iX,
                        Click_Y = iY
                    };

                    LST         = new ListViewItem(arr);
                    LST.Checked = true;
                    LST.SubItems[1].BackColor   = cColor;
                    LST.UseItemStyleForSubItems = false;
                    LST.Tag = CPf;          // Bind Model as Tag Object

                    lv.Items.Add(LST);
                }
            }
        }
Beispiel #3
0
        // 500 ms
        private void timer2_Tick(object sender, EventArgs e)
        {
            if (bPlay)
            {
                Color cColorNow = Color.Empty, cColor = Color.Empty;

                foreach (ListViewItem ITM in lv.Items)
                {
                    Models.ClickInfo Cpf = (Models.ClickInfo)ITM.Tag;

                    ITM.BackColor = Color.White;                             // Reset Color

                    cColor    = Cpf.Color;                                   // Recorded Color
                    cColorNow = GetPixelColor(Cpf.Click_X, Cpf.Click_Y);     // Screen Color

                    if (cCurColor != cColorNow)
                    {
                        iClicker = 0;
                    }

                    if (ITM.Checked && MatchColor(cColor, cColorNow, tb_tolerance.Value) && iClicker < numRetry.Value)
                    {
                        LeftClick(Cpf.Click_X, Cpf.Click_Y);

                        if (iClicker == 0)
                        {
                            Cpf.Counter++;

                            if (chkLimitClk.Checked && numLimit.Value == Cpf.Counter)
                            {
                                ITM.Checked = false;                                                        // bPlay = false;
                            }
                            ITM.SubItems[2].Text = Cpf.Counter.ToString();
                            ITM.BackColor        = Color.LightPink;
                        }

                        iClicker++;  // Repeated Click Counter
                        cCurColor = cColorNow;
                    }
                }
            }
        }