Ejemplo n.º 1
0
 public KeyModifiedStep(KeystrokesSettings Settings,
                        KeymapViewModel Keymap)
 {
     _keymap             = Keymap;
     _keystrokesSettings = Settings;
     _modifierStates     = ModifierStates.GetCurrent();
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a new instance of <see cref="MouseKeyHook"/>.
        /// </summary>
        public MouseKeyHook(MouseClickSettings MouseClickSettings,
                            KeystrokesSettings KeystrokesSettings,
                            KeymapViewModel Keymap,
                            string FileName,
                            Func <TimeSpan> Elapsed)
        {
            _mouseClickSettings = MouseClickSettings;
            _keystrokesSettings = KeystrokesSettings;
            _keymap             = Keymap;

            _hook = Hook.GlobalEvents();

            _hook.MouseDown += (S, E) =>
            {
                _mouseClicked = true;

                _mouseButtons = E.Button;
            };

            _hook.MouseUp += (S, E) => _mouseClicked = false;

            if (KeystrokesSettings.SeparateTextFile)
            {
                _textWriter = InitKeysToTextFile(FileName, Elapsed);
            }
            else
            {
                _records = new KeyRecords(KeystrokesSettings.HistoryCount);

                _hook.KeyDown += OnKeyDown;
                _hook.KeyUp   += OnKeyUp;
            }
        }
Ejemplo n.º 3
0
        public string ToString(KeymapViewModel Keymap)
        {
            var pressed = new List <string>();

            if (Control)
            {
                pressed.Add(Keymap.Control);
            }

            if (Shift)
            {
                pressed.Add(Keymap.Shift);
            }

            if (Alt)
            {
                pressed.Add(Keymap.Alt);
            }

            if (pressed.Count == 0)
            {
                return("");
            }

            return(string.Join(" + ", pressed));
        }
Ejemplo n.º 4
0
 public MouseDragStep(Point EndPoint,
                      MouseClickSettings Settings,
                      KeystrokesSettings KeystrokesSettings,
                      KeymapViewModel Keymap) : base(KeystrokesSettings, Keymap)
 {
     this.EndPoint = EndPoint;
     _settings     = Settings;
 }
Ejemplo n.º 5
0
 public MouseDragBeginStep(Point StartPoint,
                           MouseClickSettings Settings,
                           KeystrokesSettings KeystrokesSettings,
                           KeymapViewModel Keymap) : base(KeystrokesSettings, Keymap)
 {
     _start    = StartPoint;
     _settings = Settings;
 }
Ejemplo n.º 6
0
        public ScrollStep(MouseEventArgs Args,
                          MouseClickSettings Settings,
                          KeystrokesSettings KeystrokesSettings,
                          KeymapViewModel Keymap) : base(KeystrokesSettings, Keymap)
        {
            this.Args = Args;

            _settings = Settings;
        }
Ejemplo n.º 7
0
        public MouseClickStep(MouseClickSettings Settings,
                              KeystrokesSettings KeystrokesSettings,
                              MouseEventArgs Args,
                              KeymapViewModel Keymap) : base(KeystrokesSettings, Keymap)
        {
            _settings = Settings;
            this.Args = Args;

            Timestamp = DateTime.Now;
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Creates a new instance of <see cref="MouseKeyHook"/>.
        /// </summary>
        public MouseKeyHook(MouseClickSettings MouseClickSettings,
                            KeystrokesSettings KeystrokesSettings,
                            KeymapViewModel Keymap,
                            string FileName,
                            Func <TimeSpan> Elapsed)
        {
            _mouseClickSettings = MouseClickSettings;
            _keystrokesSettings = KeystrokesSettings;
            _keymap             = Keymap;

            _hook = Hook.GlobalEvents();

            _hook.MouseDown += (S, E) =>
            {
                _mouseClicked = true;

                _mouseButtons = E.Button;
            };

            _hook.MouseUp += (S, E) => _mouseClicked = false;

            if (KeystrokesSettings.SeparateTextFile)
            {
                _elapsed = Elapsed;

                var dir           = Path.GetDirectoryName(FileName);
                var fileNameWoExt = Path.GetFileNameWithoutExtension(FileName);

                var targetName = $"{fileNameWoExt}.keys.txt";

                var path = dir == null ? targetName : Path.Combine(dir, targetName);

                _keystrokeFileStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.Write, FileShare.Read);
                _textWriter          = new StreamWriter(_keystrokeFileStream);

                _hook.KeyDown += (S, E) =>
                {
                    if (!_keystrokesSettings.Display)
                    {
                        return;
                    }

                    var record = new KeyRecord(E, _keymap);

                    _textWriter.WriteLine($"{_elapsed.Invoke()}: {record.Display}");
                };
            }
            else
            {
                _records = new KeyRecords(KeystrokesSettings.HistoryCount);

                _hook.KeyDown += OnKeyDown;
                _hook.KeyUp   += OnKeyUp;
            }
        }
Ejemplo n.º 9
0
        public KeyOverlay(IMouseKeyHook Hook,
                          KeystrokesSettings Settings,
                          KeymapViewModel Keymap)
        {
            _settings = Settings;
            _keymap   = Keymap;

            _records = new KeyRecords(Settings.HistoryCount);

            Hook.KeyDown += OnKeyDown;
            Hook.KeyUp   += OnKeyUp;
        }
Ejemplo n.º 10
0
        public KeyRecord(KeyEventArgs KeyEventArgs, KeymapViewModel Keymap)
        {
            _keymap    = Keymap;
            _eventArgs = KeyEventArgs;
            TimeStamp  = DateTime.Now;

            Key     = KeyEventArgs.KeyCode;
            Control = KeyEventArgs.Control;
            Shift   = KeyEventArgs.Shift;
            Alt     = KeyEventArgs.Alt;

            _capsLock = Console.CapsLock;

            Display = GetDisplay();
        }
Ejemplo n.º 11
0
        public StepsRecorder(IMouseKeyHook Hook,
                             IVideoFileWriter VideoWriter,
                             IImageProvider ImageProvider,
                             MouseClickSettings MouseClickSettings,
                             KeystrokesSettings KeystrokesSettings,
                             StepsSettings StepsSettings,
                             KeymapViewModel KeymapViewModel)
        {
            _hook               = Hook;
            _videoWriter        = VideoWriter;
            _imageProvider      = ImageProvider;
            _stepsSettings      = StepsSettings;
            _mouseClickSettings = MouseClickSettings;
            _keystrokesSettings = KeystrokesSettings;
            _keymap             = KeymapViewModel;

            var stepsObservable = Observe(_hook, _cancellationTokenSource.Token, out var shotObservable);

            _recordTask = Task.Factory.StartNew(() => DoRecord(stepsObservable, shotObservable), TaskCreationOptions.LongRunning);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Creates a new instance of <see cref="MouseKeyHook"/>.
        /// </summary>
        public MouseKeyOverlay(MouseClickSettings MouseClickSettings,
                               KeystrokesSettings KeystrokesSettings,
                               KeymapViewModel Keymap,
                               string FileName,
                               Func <TimeSpan> Elapsed)
        {
            _keystrokesSettings = KeystrokesSettings;
            _keymap             = Keymap;

            _hook = new MouseKeyHook();
            _mouseClickOverlay = new MouseClickOverlay(_hook, MouseClickSettings);

            if (KeystrokesSettings.SeparateTextFile)
            {
                _textWriter = InitKeysToTextFile(FileName, Elapsed);
            }
            else
            {
                _keyOverlay = new KeyOverlay(_hook, KeystrokesSettings, Keymap);
            }
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Creates a new instance of <see cref="MouseKeyHook"/>.
        /// </summary>
        public MouseKeyHook(MouseClickSettings MouseClickSettings, KeystrokesSettings KeystrokesSettings, KeymapViewModel Keymap)
        {
            _mouseClickSettings = MouseClickSettings;
            _keystrokesSettings = KeystrokesSettings;
            _keymap             = Keymap;

            _hook = Hook.GlobalEvents();

            _hook.MouseDown += (S, E) =>
            {
                _mouseClicked = true;

                _mouseButtons = E.Button;
            };

            _hook.MouseUp += (S, E) => _mouseClicked = false;

            _records = new KeyRecords(KeystrokesSettings.HistoryCount);

            _hook.KeyDown += OnKeyDown;
            _hook.KeyUp   += OnKeyUp;
        }