private void Keyboard_KeyPressed(object sender, KeyEventArgs e) { if (!WaitDescriptor.IsMatch(e)) return; var time = DateTime.Now; if (time.TimeOfDay - _lastPressTime.TimeOfDay > _maxKeysPressingInterval) _currentPressCount = 0; _lastPressTime = time; lock (s_counterSync) { _currentPressCount++; } PressedKeyArgs = e; if (_currentPressCount == PressTimes) { ThreadUtils.StartBackgroundThread(WaitForSet); } }
public bool IsMatch(KeyEventArgs keyEventArgs) { if (// игнорируем нажатия клавишь s_ignoreKeys || keyEventArgs == null || !Keys.Contains(keyEventArgs.Type)) { if (AllKeysPressed) ResetMatchedKeys(); return false; } if (!AllKeysPressed) return true; var now = DateTime.Now; if (now - _lastKeyPressedTime < s_maxKeysPressingInterval) { if (!_matchedKeys.Contains(keyEventArgs.Type)) _matchedKeys.Add(keyEventArgs.Type); _lastKeyPressedTime = now; if (_matchedKeys.Count == Keys.Length) { s_ignoreKeys = true; ThreadUtils.StartBackgroundThread( () => { Thread.Sleep(TimeSpan.FromSeconds(1)); s_ignoreKeys = false; }); return true; } } else { ResetMatchedKeys(); _matchedKeys.Add(keyEventArgs.Type); _lastKeyPressedTime = now; } return false; }
private void Keyboard_KeyPressed(object sender, KeyEventArgs e) { lock (_sync) { if (!WaitDescriptor.IsMatch(e)) return; PressedKeyArgs = e; Set(); } }
private void KeyboardKeyPressed(object sender, KeyEventArgs e) { KeyPressed.RaiseEvent(sender, e); }
private void LogUserKeyPressed(object sender, KeyEventArgs e) { lock (s_pressedKeysSync) { var timeKey = DateTime.Now.Ticks; if (_pressedKeys.ContainsKey(timeKey)) { timeKey++; } _pressedKeys.Add(timeKey, e); } if (e.Type == KeyType.Quit || e.Type == KeyType.PowerOff) { LogActivityKeys(); } }