示例#1
0
 private void StopAction()
 {
     if (_currentAction == null)
     {
         return;
     }
     timer.Stop();
     if (_currentAction.Type == MouseAction.ActionType.Constant)
     {
         _currentAction.Leave();
     }
     uiTimer.Stop();
     _currentAction    = null;
     run               = -1;
     lblActive.Content = "Inactive";
     FormatActiveLabel(0);
     cbMode.IsEnabled = true;
 }
示例#2
0
        public MainWindow()
        {
            InitializeComponent();
            hotKey           = new HotKey(Key.F9, KeyModifier.Alt, OnHotKeyHandler);
            inputSimulator   = new InputSimulator();
            timer            = new Timer();
            timer.AutoReset  = true;
            timer.Elapsed   += TimerElapsed;
            uiTimer          = new DispatcherTimer();
            uiTimer.Interval = TimeSpan.FromMilliseconds(500);
            uiTimer.Tick    += UiTimerElapsed;
            run = -1;

            SpeedAndTime = new List <Tuple <Speed, int> >();
            SpeedAndTime.Add(new Tuple <Speed, int>(Speed.Slow, 1000));
            SpeedAndTime.Add(new Tuple <Speed, int>(Speed.Medium, 500));
            SpeedAndTime.Add(new Tuple <Speed, int>(Speed.Fast, 250));


            lblActiveProps = new List <LabelProps>();
            lblActiveProps.Add(new LabelProps(lblActive.Foreground, lblActive.Background));
            lblActiveProps.Add(new LabelProps(new SolidColorBrush(Color.FromRgb(255, 255, 255)), new SolidColorBrush(Color.FromRgb(255, 0, 0))));
            lblActiveProps.Add(new LabelProps(new SolidColorBrush(Color.FromRgb(255, 0, 0)), new SolidColorBrush(Color.FromRgb(255, 255, 255))));

            actions = new List <MouseAction>();
            actions.Add(new MouseAction("Click Left Mouse Button", () => { inputSimulator.Mouse.LeftButtonClick(); return(true); }));
            actions.Add(new MouseAction("Press Left Mouse Button", () => { inputSimulator.Mouse.LeftButtonDown(); return(true); }, () => { inputSimulator.Mouse.LeftButtonUp(); return(true); }));
            actions.Add(new MouseAction("Click Right Mouse Button", () => { inputSimulator.Mouse.RightButtonClick(); return(true); }));
            actions.Add(new MouseAction("Press Right Mouse Button", () => { inputSimulator.Mouse.RightButtonDown(); return(true); }, () => { inputSimulator.Mouse.RightButtonUp(); return(true); }));
            _currentAction = null;

            foreach (var action in actions)
            {
                cbMode.Items.Add(action.Description);
            }

            foreach (var speedAndTime in SpeedAndTime)
            {
                cbSpeed.Items.Add(speedAndTime.Item1.ToString());
            }

            cbSpeed.SelectedIndex = 1;
            cbMode.SelectedIndex  = 0;
        }
示例#3
0
        private void StartAction()
        {
            cbMode.IsEnabled = false;
            _currentAction   = getSelectedAction();

            if (_currentAction.Type == MouseAction.ActionType.Constant)
            {
                _currentAction.Enter();
            }
            else
            {
                timer.Interval = GetSpeed().Item2;
                timer.Start();
            }
            uiTimer.Start();
            run = 0;
            lblActive.Content = "ACTIVE";
            FormatActiveLabel(2);
        }