static public WindowsInput.Native.VirtualKeyCode?WindowsInputVirtualKeyCodeBerecneAusSystemWindowsInputKey( System.Windows.Input.Key WindowsInputKey) { if (System.Windows.Input.Key.F1 <= WindowsInputKey && WindowsInputKey <= System.Windows.Input.Key.F24) { return((WindowsInput.Native.VirtualKeyCode)(((int)WindowsInputKey - (int)System.Windows.Input.Key.F1) + (int)WindowsInput.Native.VirtualKeyCode.F1)); } if (System.Windows.Input.Key.D0 <= WindowsInputKey && WindowsInputKey <= System.Windows.Input.Key.D9) { return((WindowsInput.Native.VirtualKeyCode)(((int)WindowsInputKey - (int)System.Windows.Input.Key.D0) + (int)WindowsInput.Native.VirtualKeyCode.VK_0)); } var WindowsInputKeySictString = WindowsInputKey.ToString(); WindowsInput.Native.VirtualKeyCode Result; if (Enum.TryParse(WindowsInputKeySictString, false, out Result)) { return(Result); } if (Enum.TryParse(WindowsInputKeySictString, true, out Result)) { return(Result); } return(null); }
public static bool IsNumericKey(System.Windows.Input.Key key) { switch (key) { case System.Windows.Input.Key.NumPad0: case System.Windows.Input.Key.NumPad1: case System.Windows.Input.Key.NumPad2: case System.Windows.Input.Key.NumPad3: case System.Windows.Input.Key.NumPad4: case System.Windows.Input.Key.NumPad5: case System.Windows.Input.Key.NumPad6: case System.Windows.Input.Key.NumPad7: case System.Windows.Input.Key.NumPad8: case System.Windows.Input.Key.NumPad9: case System.Windows.Input.Key.D0: case System.Windows.Input.Key.D1: case System.Windows.Input.Key.D2: case System.Windows.Input.Key.D3: case System.Windows.Input.Key.D4: case System.Windows.Input.Key.D5: case System.Windows.Input.Key.D6: case System.Windows.Input.Key.D7: case System.Windows.Input.Key.D8: case System.Windows.Input.Key.D9: { return(true); } } return(false); }
/// <summary> /// Translates the WPF key to Toolkit key and invokes status change /// </summary> /// <remarks>For modifier keys (Shift, Control, Alt) will invoke its Left... analog additionally</remarks> /// <param name="keyCode">WPF key code to be translated</param> /// <param name="keyAction">delegate to invoke with translated key</param> private static void ProcessKeyEvent(WpfKeys keyCode, Action <Keys> keyAction) { Keys translatedKey; if (!_keysDictionaryWpf.TryGetValue(keyCode, out translatedKey)) { translatedKey = Keys.None; } keyAction(translatedKey); // XNA doesn't have handless modifier keys, so we will map general keys to left ones: // TODO: consider P/Invoke to get pressed keys and/or determine which key was pressed switch (translatedKey) { case Keys.Shift: keyAction(Keys.LeftShift); break; case Keys.Control: keyAction(Keys.LeftControl); break; case Keys.Alt: keyAction(Keys.LeftAlt); break; } }
public KeyInfo(System.Windows.Input.Key key, bool shift, bool nonPrintKey = false) { this.key = key; this.shift = shift; this.nonPrintKey = nonPrintKey; }
public void AssignKeyAction(string key, System.Windows.Input.Key value) { Key keys; Enum.TryParse(value.ToString(), out keys); controlSettings.KeyboardAssignment[key] = keys; }
public string GetFileNameAndPageForKey(System.Windows.Input.Key key) { int i = -1; string result = ""; switch (key) { case System.Windows.Input.Key.D0: { i = 0; break; } case System.Windows.Input.Key.D1: { i = 1; break; } case System.Windows.Input.Key.D2: { i = 2; break; } case System.Windows.Input.Key.D3: { i = 3; break; } case System.Windows.Input.Key.D4: { i = 4; break; } case System.Windows.Input.Key.D5: { i = 5; break; } case System.Windows.Input.Key.D6: { i = 6; break; } case System.Windows.Input.Key.D7: { i = 7; break; } case System.Windows.Input.Key.D8: { i = 8; break; } case System.Windows.Input.Key.D9: { i = 9; break; } default: { i = -1; break; } } if ((i >= 0) && (i < this.list.ShowMaxEntries)) { result = this.list[i].FullFileName + ',' + this.list[i].PageNumber.ToString(); } return(result); }
private void SetHotKeyFromWindow(GLOBAL_HOT_KEY_TYPE type, CheckBox alt_box, CheckBox cntrl_box, CheckBox shift_box, CheckBox win_box, TextBox txt_box) { System.Windows.Input.Key hot_key = System.Windows.Input.Key.None; var hot_key_modifier = UnManaged.KeyModifier.None; if (alt_box.IsChecked == true) { hot_key_modifier |= UnManaged.KeyModifier.Alt; } if (cntrl_box.IsChecked == true) { hot_key_modifier |= UnManaged.KeyModifier.Ctrl; } if (shift_box.IsChecked == true) { hot_key_modifier |= UnManaged.KeyModifier.Shift; } if (win_box.IsChecked == true) { hot_key_modifier |= UnManaged.KeyModifier.Win; } if (!String.IsNullOrWhiteSpace(txt_box.Text)) { var key = txt_box.Text.ToUpper(); if (key[0] >= 0 && key[0] <= 9) { key = "D" + key; } Enum.TryParse <System.Windows.Input.Key>(key, out hot_key); } broker.SetHotKey(type, new Broker.HotKeySetting { modifiers = hot_key_modifier, key = hot_key }); }
public static void SendThreeKeys(System.Windows.Input.Key key1, System.Windows.Input.Key key2, System.Windows.Input.Key key3, string msg, int sleepTime) { Thread.Sleep(sleepTime); Library.ValidateArgumentNonNull(msg, "SendSingleKey() msg argument is null"); if (msg.Length > 0) { msg = msg + " by "; } /* changing to new flexible logging */ //Logger.LogComment(msg + "Sending keys " + key1.ToString() + ", " + key2.ToString() + " + " + key3.ToString()); UIVerifyLogger.LogComment(msg + "Sending keys " + key1.ToString() + ", " + key2.ToString() + " + " + key3.ToString()); ATGTestInput.Input.SendKeyboardInput(key1, true); Thread.Sleep(300); ATGTestInput.Input.SendKeyboardInput(key2, true); Thread.Sleep(300); ATGTestInput.Input.SendKeyboardInput(key3, true); Thread.Sleep(sleepTime); ATGTestInput.Input.SendKeyboardInput(key3, false); ATGTestInput.Input.SendKeyboardInput(key1, false); ATGTestInput.Input.SendKeyboardInput(key2, false); Thread.Sleep(sleepTime); }
private void OnKeyEvent(System.Windows.Input.Key key, System.Func <bool>[] binding) { if (System.Windows.Input.Key.A <= key && key <= System.Windows.Input.Key.Z) { binding[(int)key]?.Invoke(); } }
public static bool IsInteger(this System.Windows.Input.Key key) { bool result = ((key >= System.Windows.Input.Key.D0 && key <= System.Windows.Input.Key.D9) || (key >= System.Windows.Input.Key.NumPad0 && key <= System.Windows.Input.Key.NumPad9) || key == System.Windows.Input.Key.Back || key == System.Windows.Input.Key.Delete); return(result); }
public GlobalKeyboardHookEventArgs( GlobalKeyboardHook.LowLevelKeyboardInputEvent keyboardData, GlobalKeyboardHook.KeyboardState keyboardState) { KeyboardData = keyboardData; KeyboardState = keyboardState; Key = System.Windows.Input.KeyInterop.KeyFromVirtualKey(KeyboardData.VirtualCode); }
public void KeyCodeEnterred(System.Windows.Input.Key key) { IOperation?newOperation = _KeyMapping.ContainsKey(key) ? _KeyMapping[key]() : null; if (newOperation != null) { AddOperation(newOperation); } }
public static bool IsNumeric(this System.Windows.Input.Key key) { bool result = ((key >= System.Windows.Input.Key.D0 && key <= System.Windows.Input.Key.D9) || (key >= System.Windows.Input.Key.NumPad0 && key <= System.Windows.Input.Key.NumPad9) || key == System.Windows.Input.Key.Back || key == System.Windows.Input.Key.Delete || key == System.Windows.Input.Key.Decimal || key == System.Windows.Input.Key.OemPeriod); return(result); }
public LLRecordEntry(string path, bool isKeyUp, System.Windows.Input.Key key, string type) : this() { codePath = path; IsKeyUp = isKeyUp; Key = key; this.type = type; }
public override bool ProcessKeyDown( CanonicalMouseEventArgs e, System.Windows.Input.Key key, System.Windows.Input.ModifierKeys modifierKeys, InteractionContext context ) { MessageBox.Show(e.GetWcsPosition(context).ToString()); return(true); }
public static Key FromSystemKey(System.Windows.Input.Key SystemKey) { if (Enum.TryParse(SystemKey.ToString(), out Key DirectKey)) { return(DirectKey); } Debug.WriteLine($"Warning; SystemKey '{SystemKey}' does not have a direct {nameof(Key)} conversion."); return((Key)SystemKey); }
internal KeyboardElement FindKeyboardElementByKey(Key key) { KeyboardElement result; if (!notes.TryGetValue(key, out result)) { return(null); } return(result); } //FindKeyboardElementByKey
private void MainWindow_KeyDown(object sender, System.Windows.Input.KeyEventArgs e) { string s = e.Key.ToString(); System.Windows.Input.Key k = e.Key; int i = (int)k; this.Title = s + i.ToString(); // Display key press on the button. btnExitApp.Content = e.Key.ToString(); }
public void AddOrReplace(string name, System.Windows.Input.Key key, System.Windows.Input.ModifierKeys modifierKeys) { try { HotkeyManager.Current.AddOrReplace(name, key, modifierKeys, this.OnHotKeyPressed); } catch (HotkeyAlreadyRegisteredException e) { this.HotkeyAlreadyRegistered?.Invoke(this, new MappedHotkeyAlreadyRegisteredEventArgs(e.Name)); } }
private void GlControlHost_PreviewKeyDown(object sender, System.Windows.Input.KeyEventArgs e) { System.Windows.Input.Key input_key = e.Key; if (input_key == System.Windows.Input.Key.System) { input_key = e.SystemKey; } WInput.SetKeyboardState(input_key, true); }
/// <inheritdoc/> public bool IsUp(Keys key) { if (key == Keys.CapsLock) { // Special handling of Caps Lock. return (((ushort)GetKeyState(0x14)) & 0xffff) == 0; } return _newKeyboardState.IsKeyUp(key); }
/// <inheritdoc/> public bool IsUp(Keys key) { #if WINDOWS if (key == Keys.CapsLock) { // Special handling of Caps Lock. return((((ushort)GetKeyState(0x14)) & 0xffff) == 0); } #endif return(_newKeyboardState.IsKeyUp(key)); }
/// <inheritdoc/> public bool IsPressed(Keys key, bool useKeyRepetition) { if (useKeyRepetition) { if (_lastKey.Button == key && _lastKey.IsVirtualPress) { return(true); } } return(_newKeyboardState.IsKeyDown(key) && _previousKeyboardState.IsKeyUp(key)); }
public void OnKeyDown(System.Windows.Input.Key theKey) { if (theKey == System.Windows.Input.Key.LeftShift || theKey == System.Windows.Input.Key.RightShift) { CurrentPressedKey = CurrentPressedKey.CurPressedKey_Shift; } else if (theKey == System.Windows.Input.Key.LeftCtrl || theKey == System.Windows.Input.Key.RightCtrl) { CurrentPressedKey = CurrentPressedKey.CurPressedKey_Ctrl; } }
/// <summary> /// Injects a key. /// </summary> /// <param name="strKey">The string value of the key to inject.</param> /// <param name="boolPress">Specifies whether the button is pressed or not.</param> public static void KeyPress(string strKey, bool boolPress) { System.Windows.Input.Key key = GetKeyFromString(strKey); if (key != System.Windows.Input.Key.None) { KeyPress(key, boolPress); } else { Console.WriteLine("Invalid strKey - " + strKey); } }
public static int ConvertToBarcodeChar(System.Windows.Input.Key key) { int keyInt = (int)key; if (keyInt >= 34 && keyInt <= 43) { return('0' + (keyInt - 34)); } else if (keyInt >= 44 && keyInt <= 69) { return('A' + (keyInt - 44)); } return(0); }
public void StringToKey() { TypeConverter keyConverter = TypeDescriptor.GetConverter(typeof(System.Windows.Input.Key)); try { this.HotKeyCode = (System.Windows.Input.Key)keyConverter.ConvertFromString(this.keysArray[this.keysArray.Length - 1]); this.error = false; } catch (Exception E) { this.error = true; //MessageBox.Show(E.Message, "Hot Key cannot be registered", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/* * This method performs the lookup and returns the VirtualKeyCode if it is found. * If it is not found, a 0 is returned. */ public static WindowsInput.VirtualKeyCode LookupVKey(System.Windows.Input.Key enumKey) { // Since vKey cannot be null, use 0 to represent an invalid key WindowsInput.VirtualKeyCode vKey = 0; try { lookup.TryGetValue(enumKey, out vKey); } catch (ArgumentException) { Console.WriteLine("Invalid key" + enumKey.ToString()); } return(vKey); }
/// <summary> /// Class constructor /// </summary> public BlockDefinition(string blockstart, string blockend, BlockAt typeOfBlock, string fileextension, System.Windows.Input.Key key, System.Windows.Input.ModifierKeys modifier = 0) : this() { this.TypeOfBlock = typeOfBlock; this.StartBlock = blockstart; this.EndBlock = blockend; this.FileExtension = fileextension; this.Key = key; this.Modifier = modifier; }
/// <summary> /// 通过KEY返回值 /// </summary> /// <param name="key"></param> /// <returns></returns> internal string GetStrFromKey(System.Windows.Input.Key key) { if (key >= System.Windows.Input.Key.D0 && key <= System.Windows.Input.Key.D9) { return(key.ToString().TrimStart("D")); } else if (key >= System.Windows.Input.Key.NumPad0 && key <= System.Windows.Input.Key.NumPad9) { return(key.ToString().TrimStart("NumPad")); } else if (key == System.Windows.Input.Key.OemPeriod || key == System.Windows.Input.Key.Decimal) { return("."); } return(key.ToString()); }
public loopEvent(Int64 tickNumarg, System.Windows.Input.Key keyvalarg) { this.tickNum = tickNumarg; this.keyval = keyvalarg; }
/// <inheritdoc/> public bool IsPressed(Keys key, bool useKeyRepetition) { if (useKeyRepetition) { if (_lastKey.Button == key && _lastKey.IsVirtualPress) { return true; } } return _newKeyboardState.IsKeyDown(key) && _previousKeyboardState.IsKeyUp(key); }
/// <summary> /// Create raw keyevent arguments. /// </summary> /// <param name="VKCode"></param> /// <param name="isSysKey"></param> public RawKeyEventArgs(int VKCode, bool isSysKey) { this.VKCode = VKCode; this.IsSysKey = isSysKey; this.Key = System.Windows.Input.KeyInterop.KeyFromVirtualKey(VKCode); }
/// <summary> /// Converts a System.Windows.Input.Key to an Sce.Atf.Input.Keys</summary> /// <param name="wpfKey">WpfKey enum</param> /// <returns>Converted AtfKeys enum</returns> public static AtfKeys ToAtf(WpfKey wpfKey) { return (AtfKeys)System.Windows.Input.KeyInterop.VirtualKeyFromKey(wpfKey); }
/// <summary> /// Translates the WPF key to Toolkit key and invokes status change /// </summary> /// <remarks>For modifier keys (Shift, Control, Alt) will invoke its Left... analog additionally</remarks> /// <param name="keyCode">WPF key code to be translated</param> /// <param name="keyAction">delegate to invoke with translated key</param> private static void ProcessKeyEvent(WpfKeys keyCode, Action<Keys> keyAction) { Keys translatedKey; if (!_keysDictionaryWpf.TryGetValue(keyCode, out translatedKey)) translatedKey = Keys.None; keyAction(translatedKey); // XNA doesn't have handless modifier keys, so we will map general keys to left ones: // TODO: consider P/Invoke to get pressed keys and/or determine which key was pressed switch (translatedKey) { case Keys.Shift: keyAction(Keys.LeftShift); break; case Keys.Control: keyAction(Keys.LeftControl); break; case Keys.Alt: keyAction(Keys.LeftAlt); break; } }
/// <inheritdoc/> public bool IsDoubleClick(Keys key) { return _lastKey.Button == key && _lastKey.IsDoubleClick; }
/// <inheritdoc/> public bool IsUp(Keys key) { #if WINDOWS if (key == Keys.CapsLock) { // Special handling of Caps Lock. return (((ushort)GetKeyState(0x14)) & 0xffff) == 0; } #endif return _newKeyboardState.IsKeyUp(key); }
/// <inheritdoc/> public bool IsReleased(Keys key) { return _newKeyboardState.IsKeyUp(key) && _previousKeyboardState.IsKeyDown(key); }
public bool IsKeyToggled(Keys vKey) { return KB.IsKeyToggled(vKey); }
public bool IsKeyDown(Keys vKey) { return KB.IsKeyDown(vKey); }
public char this[Keys key, ModifierKeys modifierKeys] { get { // Get variants (different modifiers results) for the specified key. Dictionary<int, char> keyVariants; bool exists = _map.TryGetValue((int)key, out keyVariants); if (!exists) return '\0'; // Get character for the given modifier. char c; exists = keyVariants.TryGetValue((int)modifierKeys, out c); if (!exists) return '\0'; return c; } set { Dictionary<int, char> keyVariants; bool exists = _map.TryGetValue((int)key, out keyVariants); if (!exists) { // No entries for key exist. // Add new dictionary for the key and its variants. keyVariants = new Dictionary<int, char>(); _map.Add((int)key, keyVariants); } // Add new key variant or change existing one. exists = keyVariants.ContainsKey((int)modifierKeys); if (!exists) keyVariants.Add((int)modifierKeys, value); else keyVariants[(int)modifierKeys] = value; } }