public void SetWindow(string window) { this.window = window; if (WinUtils.GetActiveWindow() != this.window) { Stop(); } }
public static void Send(Keyboard.ScanCodeShort key) { if (WinUtils.GetActiveWindow() != WindowToSendKeysIn || _currentKey != null) { return; } _currentKey = key; _keyboard.Send(_currentKey.Value); _timerCombination.Restart(); }
public static bool IsCharDown(char c) { if (WinUtils.GetActiveWindow() != WindowToSendKeysIn) { return(false); } lock (mutex) { var key = GetScanCode(c); return(_keyboard.IsDown(key)); } }
public static void SendCharUp(char c) { if (WinUtils.GetActiveWindow() != WindowToSendKeysIn || !_active) { return; } lock (mutex) { var key = GetScanCode(c); _keyboard.SendUp(key); _timerRepeat.Stop(); _repeatKey = null; } }
public void SendDown(ScanCodeShort key) { if (WinUtils.GetActiveWindow() != this.window) { Stop(); return; } else if (IsKeyDownTimerActive(key)) { Debug.Log("This key is already being pressed"); return; } VirtualKeyShort code = GetVK(key); SendInput(code, key); }
public static void SendMessage(string message, Action callback = null) { if (WinUtils.GetActiveWindow() != WindowToSendKeysIn || !_active) { return; } else if (_currentKey != null || string.IsNullOrEmpty(message)) { return; } lock (mutex) { _currentCombination = GetCombination(message); _callbackMultipleKey = callback; } OnKeyTimer(null, null); }
public static void SendChar(char c, float duration = Keyboard.KEY_DOWN_TIME, Action callback = null) { if (WinUtils.GetActiveWindow() != WindowToSendKeysIn || !_active) { return; } lock (mutex) { if (_currentKey != null) { return; } _currentKey = GetScanCode(c); _keyboard.SendUp(_currentKey.Value); _keyboard.Send(_currentKey.Value, duration, callback); _timerCombination.Restart(); } }
private void OnKeyDownTimerOver(object sender, ElapsedEventArgs e) { if (WinUtils.GetActiveWindow() != this.window) { Stop(); return; } Timer timer = sender as Timer; timer.Stop(); var tuple = TryGetTupleForTimer(timer); if (tuple != null) { VirtualKeyShort code = GetVK(tuple.Item1); SendInput(code, tuple.Item1, KEYEVENTF.KEYUP); tuple.Item2?.Invoke(); } }
public static void SendCombination(EKeyCombination keys, Action callback = null) { if (WinUtils.GetActiveWindow() != WindowToSendKeysIn) { return; } if (!_keyCombinations.ContainsKey(keys)) { Debug.Log("Key map does not contain combination: " + keys.ToString()); return; } if (_currentCombination != null) { Debug.Log("A combination is already running"); return; } _callbackMultipleKey = callback; _currentCombination = GetKeyCombinations(keys); _timerCombination.Restart(); }