/// <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; } }
/// <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; } }
public KeyOverlay(IMouseKeyHook Hook, KeystrokesSettings Settings, KeymapViewModel Keymap) { _settings = Settings; _keymap = Keymap; _records = new KeyRecords(Settings.HistoryCount); Hook.KeyDown += OnKeyDown; Hook.KeyUp += OnKeyUp; }
/// <summary> /// Creates a new instance of <see cref="MouseKeyHook"/>. /// </summary> public MouseKeyHook(MouseClickSettings MouseClickSettings, KeystrokesSettings KeystrokesSettings) { _mouseClickSettings = MouseClickSettings; _keystrokesSettings = KeystrokesSettings; _hook = Hook.GlobalEvents(); _hook.MouseDown += (S, E) => _mouseClicked = true; _hook.MouseUp += (S, E) => _mouseClicked = false; _records = new KeyRecords(KeystrokesSettings.HistoryCount); _hook.KeyDown += OnKeyDown; _hook.KeyUp += OnKeyUp; }
/// <summary> /// Creates a new instance of <see cref="MouseKeyHook"/>. /// </summary> /// <param name="CaptureMouseClicks">Whether to capture Mouse CLicks.</param> /// <param name="CaptureKeystrokes">Whether to capture Keystrokes.</param> public MouseKeyHook(bool CaptureMouseClicks, bool CaptureKeystrokes) { _records = new KeyRecords(Settings.Instance.Keystrokes_History_Count); _hook = Hook.GlobalEvents(); if (CaptureMouseClicks) { _hook.MouseDown += (s, e) => _mouseClicked = true; _hook.MouseUp += (s, e) => _mouseClicked = false; } if (CaptureKeystrokes) { _hook.KeyDown += OnKeyDown; _hook.KeyUp += OnKeyUp; } }
/// <summary> /// Creates a new instance of <see cref="MouseKeyHook"/>. /// </summary> public MouseKeyHook(MouseClickSettings MouseClickSettings, KeystrokesSettings KeystrokesSettings, KeymapViewModel Keymap, KeyVector keyVector) { _mouseClickSettings = MouseClickSettings; _keystrokesSettings = KeystrokesSettings; _keymap = Keymap; _keyVector = keyVector; _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; }