예제 #1
0
        private void Handler()
        {
            _interruptFlag = false;

            Task t = Task.Run(() =>
            {
                long clickCounter = 0;

                if (ClickedMouseButton.HasFlag(MouseButtons.Left))
                {
                    _stopWatch.Start();
                    while (!_interruptFlag)
                    {
                        MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.LeftDown);
                        Thread.Sleep(PressDuration);
                        MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.LeftUp);
                        Thread.Sleep(RepeatDelay);
                        clickCounter++;
                    }
                    _stopWatch.Stop();
                }
                else if (ClickedMouseButton.HasFlag(MouseButtons.Right))
                {
                    _stopWatch.Start();
                    while (!_interruptFlag)
                    {
                        MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.RightDown);
                        Thread.Sleep(PressDuration);
                        MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.RightUp);
                        Thread.Sleep(RepeatDelay);
                        clickCounter++;
                    }
                    _stopWatch.Stop();
                }

                /*StatisticsRecorder._stopWatch.Start();
                 * while (!_interruptFlag)
                 * {
                 *  if (ClickedMouseButton.HasFlag(MouseButtons.Left))
                 *      MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.LeftDown);
                 *  else if (ClickedMouseButton.HasFlag(MouseButtons.Right))
                 *      MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.RightDown);
                 *
                 *  Thread.Sleep(PressDuration);
                 *
                 *  if (ClickedMouseButton.HasFlag(MouseButtons.Left))
                 *      MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.LeftUp);
                 *  else if (ClickedMouseButton.HasFlag(MouseButtons.Right))
                 *      MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.RightUp);
                 *
                 *  Thread.Sleep(RepeatDelay);
                 *  clickCounter++;
                 * }*/

                //StatisticsRecorder._stopWatch.Stop();
                StatisticsRecorder.FinishTest(clickCounter, _stopWatch.ElapsedMilliseconds);
                _stopWatch.Reset();
            });
        }
예제 #2
0
        private void Handler(MouseButtons trigger)
        {
            if (_triggerProtection)
            {
                return;
            }

            if (RepeatedMouseButton.HasFlag(trigger))
            {
                _triggerProtection = true;

                Task t = Task.Run(() =>
                {
                    for (int i = 0; i < Repeats; i++)
                    {
                        if (i > 0 && RepeatDelay > 0)
                        {
                            Thread.Sleep(RepeatDelay);
                        }

                        if (trigger.HasFlag(MouseButtons.Left))
                        {
                            MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.LeftDown);
                        }
                        else if (trigger.HasFlag(MouseButtons.Right))
                        {
                            MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.RightDown);
                        }
                        else if (trigger.HasFlag(MouseButtons.Middle))
                        {
                            MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.MiddleDown);
                        }

                        Thread.Sleep(PressDuration);

                        if (trigger.HasFlag(MouseButtons.Left))
                        {
                            MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.LeftUp);
                        }
                        else if (trigger.HasFlag(MouseButtons.Right))
                        {
                            MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.RightUp);
                        }
                        else if (trigger.HasFlag(MouseButtons.Middle))
                        {
                            MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.MiddleUp);
                        }
                    }

                    _triggerProtection = false;
                });
            }
        }