public HubClientModifier(HubAppClient hubClient, HubClientAppContext appContext, ModifierModel model) { this.hubClient = hubClient; this.appContext = appContext; ID = new EntityID(model.ID); modKey = new ModifierKey(model.ModKey); }
public HotKey(Keys key, ModifierKey modifiers, IntPtr handle) : base() { Key = key; Modifiers = modifiers; Handle = handle; _disposed = true; }
private static string ApplyModifierKey(string keyStrokes, ModifierKey key) { string returnString = keyStrokes; if ((key & ModifierKey.Alt) == ModifierKey.Alt) { string formatString = "{{ALT DOWN}}{0}{{ALT UP}}"; returnString = string.Format(formatString, returnString); } if ((key & ModifierKey.Shift) == ModifierKey.Shift) { string formatString = "{{SHIFT DOWN}}{0}{{SHIFT UP}}"; returnString = string.Format(formatString, returnString); } if ((key & ModifierKey.Control) == ModifierKey.Control) { string formatString = "{{CONTROL DOWN}}{0}{{CONTROL UP}}"; returnString = string.Format(formatString, returnString); } if ((key & ModifierKey.Windows) == ModifierKey.Windows) { string formatString = "{{WIN DOWN}}{0}{{WIN UP}}"; returnString = string.Format(formatString, returnString); } return(returnString); }
public void SetShortcut(ModifierKey modifier, Key key) { string shortcut = KeyMapper.GetShortcut(modifier, key); using GLibString gshortcut = shortcut; Gtk.Menu.SetAccelerator(Handle, gshortcut); }
public static NSEventModifierFlags GetModifier(ModifierKey key) { NSEventModifierFlags result = NSEventModifierFlags.None; foreach (var flag in EnumTools.GetFlags(key)) { switch (flag) { case ModifierKey.None: continue; case ModifierKey.Shift: result |= NSEventModifierFlags.Shift; break; case ModifierKey.Control: result |= NSEventModifierFlags.Control; break; case ModifierKey.Alt: result |= NSEventModifierFlags.Option; break; case ModifierKey.Super: case ModifierKey.Primary: result |= NSEventModifierFlags.Command; break; default: throw new NotSupportedException($"Unsupported modifier key: \"{flag}\""); } } return(result); }
private static void MapModifier(StringBuilder builder, ModifierKey modifier) { foreach (var flag in EnumTools.GetFlags(modifier)) { string value; switch (flag) { case ModifierKey.None: continue; case ModifierKey.Shift: value = "<Shift>"; break; case ModifierKey.Control: value = "<Control>"; break; case ModifierKey.Alt: value = "<Alt>"; break; case ModifierKey.Super: case ModifierKey.Primary: value = "<Super>"; break; default: throw new NotSupportedException($"Unsupported modifier key: \"{flag}\""); } builder.Append(value); } }
public static bool IsModifierEnumMatch(Event current, ModifierKey modifier) { return(current.shift && modifier == ModifierKey.SHIFT || current.alt && modifier == ModifierKey.ALT || current.control && modifier == ModifierKey.CTRL || (!current.shift && !current.alt && !current.control && modifier == ModifierKey.NONE)); }
private static Keys MapModifier(ModifierKey modifier) { var result = Keys.None; foreach (var flag in EnumTools.GetFlags(modifier)) { switch (flag) { case ModifierKey.None: continue; case ModifierKey.Shift: result |= Keys.Shift; break; case ModifierKey.Control: case ModifierKey.Primary: result |= Keys.Control; break; case ModifierKey.Alt: result |= Keys.Alt; break; case ModifierKey.Super: result |= Keys.LWin; break; default: throw new NotSupportedException($"Unsupported modifier key: \"{flag}\""); } } return(result); }
private void kHook_KeyDown(object sender, KeyboardHookEventArgs e) { switch (e.KeyString) { case "[LShiftKey]": _activeModifier = _activeModifier.Add(ModifierKey.Shift); break; case "[LControlKey]": _activeModifier = _activeModifier.Add(ModifierKey.Ctrl); break; case "[LMenu]": _activeModifier = _activeModifier.Add(ModifierKey.Alt); break; case "\\": _activeModifier = _activeModifier.Add(ModifierKey.Console); break; default: ProcessKey(e.Char); break; } }
public static void ReleaseModifierKey(ModifierKey modifierKey) { string keystrokes = string.Empty; if ((modifierKey & ModifierKey.Alt) == ModifierKey.Alt) { keystrokes += "{ALT UP}"; } if ((modifierKey & ModifierKey.Shift) == ModifierKey.Shift) { keystrokes += "{SHIFT UP}"; } if ((modifierKey & ModifierKey.Control) == ModifierKey.Control) { keystrokes += "{CONTROL UP}"; } if ((modifierKey & ModifierKey.Windows) == ModifierKey.Windows) { keystrokes += "{WIN UP}"; } if (keystrokes != string.Empty) { Log.Comment("Send text '{0}'.", keystrokes); TextInput.SendText(keystrokes); Wait.ForIdle(); } }
public static void HoldKeyMilliSeconds(Key key, uint milliseconds, ModifierKey modifierKey = ModifierKey.None, bool useDebugMode = false) { if (useDebugMode) { Log.Comment("Holding down key: {0} for {1} milliseconds.", key, milliseconds); } // Remove starting and ending curly bracket. var cleanedName = keyToKeyStringDictionary[key].Substring(1).Replace("}", ""); string beginKeyStroke = GetPressDownModifierKeyStroke(modifierKey) + "{" + cleanedName + " DOWN}"; string endKeyStroke = "{" + cleanedName + " UP}" + GetReleaseModifierKeyStroke(modifierKey); TextInput.SendText(beginKeyStroke); Wait.ForMilliseconds(milliseconds); TextInput.SendText(endKeyStroke); if (useDebugMode) { Log.Comment($"Pressed key for {milliseconds} milliseconds."); } Wait.ForIdle(); if (useDebugMode) { Log.Comment("Exiting HoldKeyForMilliSeconds."); } }
public static string GetReleaseModifierKeyStroke(ModifierKey modifierKey) { string keystrokes = string.Empty; if ((modifierKey & ModifierKey.Alt) == ModifierKey.Alt) { keystrokes += "{ALT UP}"; } if ((modifierKey & ModifierKey.Shift) == ModifierKey.Shift) { keystrokes += "{SHIFT UP}"; } if ((modifierKey & ModifierKey.Control) == ModifierKey.Control) { keystrokes += "{CONTROL UP}"; } if ((modifierKey & ModifierKey.Windows) == ModifierKey.Windows) { keystrokes += "{WIN UP}"; } return(keystrokes); }
public static string GetPressDownModifierKeyStroke(ModifierKey modifierKey) { string keystrokes = string.Empty; if ((modifierKey & ModifierKey.Alt) == ModifierKey.Alt) { keystrokes += "{ALT DOWN}"; } if ((modifierKey & ModifierKey.Shift) == ModifierKey.Shift) { keystrokes += "{SHIFT DOWN}"; } if ((modifierKey & ModifierKey.Control) == ModifierKey.Control) { keystrokes += "{CONTROL DOWN}"; } if ((modifierKey & ModifierKey.Windows) == ModifierKey.Windows) { keystrokes += "{WIN DOWN}"; } return(keystrokes); }
public static void SendKeyPress(IntPtr gameWindow, VirtualKeyCode key, VirtualKeyCode?modifier) { using (var modifierKey = new ModifierKey(gameWindow, modifier)) { KeyPress(gameWindow, key); } }
// finds and uses a key macro private bool FindKeyMacro(int vk, bool isDown) { bool passKey = true; ModifierKey modifiers = Macro.GetCurrentModifierKeys(vk); foreach (Trigger trig in macro_table.Keys) { if (trig.CanTrigger(isDown, vk, modifiers)) { CompiledMacro macro = macro_table[trig]; if (macro.TimeSinceLastRun > settings._macroActivationDelay) { macro.Execute(); } if (macro.HasTableSwitch) { SwitchMacroTable(macro.TableSwitchIdx); } // Only pass if the key was not already down. Otherwise, use macro.passOriginalKey passKey = macro.PassOriginalKey; if (isDown) { prevMacroVk = vk; } break; } } bool tempResult = passKey && (isDown ^ IsKeyDepressed(vk)); //System.Diagnostics.Debug.WriteLine(Macro.GetKeyString(vk, ModifierKey.None) + ": " + tempResult.ToString()); return(tempResult); //let it pass }
public void SetElementsSelection(CustomEditorElementControl elementCtrl, ModifierKey modKey) { if (modKey == ModifierKey.Ctrl) { elementCtrl.IsSelected = !elementCtrl.IsSelected; this.baseIndex = this.GetIndexOfElement(elementCtrl); } else if (modKey == ModifierKey.Shift) { int currentIdx = this.GetIndexOfElement(elementCtrl); if (currentIdx >= 0 && this.baseIndex >= 0) { this.UnselectElements(); int minIdx = System.Math.Min(currentIdx, this.baseIndex); int maxIdx = System.Math.Max(currentIdx, this.baseIndex); this.SetElementsSelection(minIdx, maxIdx); } } else { this.UnselectElements(); elementCtrl.IsSelected = true; this.baseIndex = this.GetIndexOfElement(elementCtrl); } }
private static void MapModifier(StringBuilder builder, ModifierKey modifier) { switch (modifier) { case ModifierKey.None: return; case ModifierKey.Shift: builder.Append("Shift"); break; case ModifierKey.Control: builder.Append("Ctrl"); break; case ModifierKey.Alt: builder.Append("Alt"); break; case ModifierKey.Control | ModifierKey.Shift: builder.Append("CtrlShift"); break; case ModifierKey.Super: case ModifierKey.Primary: default: throw new NotSupportedException($"Unsupported modifier key: \"{modifier}\""); } }
internal async Task <Modifier> Modifier(ModifierCategory modCategory, ModifierKey modKey) { if ( !modCategory.Name().Equals(ModifierCategoryName.Default) && modKey.Equals(ModifierKey.Default) ) { var app = await modCategory.App(); modCategory = await app.ModCategory(ModifierCategoryName.Default); } var record = await factory.DB .Modifiers .Retrieve() .Where(m => m.CategoryID == modCategory.ID.Value && m.ModKey == modKey.Value) .FirstOrDefaultAsync(); if (record == null) { record = await factory.DB .Modifiers .Retrieve() .Where(m => m.ModKey == ModifierKey.Default.Value) .FirstOrDefaultAsync(); } return(factory.Modifier(record)); }
private static void Main() { var instructional = new InstructionalButtons(); var spawnCarGroup = new InstructionalButtonGroup("Spawn Car", ModifierKey.GetInstructionalKey(), InstructionalKey.SymbolPlus, SpawnCarKey.GetInstructionalKey()); instructional.Buttons.Add(spawnCarGroup); while (true) { GameFiber.Yield(); if (HasInputJustChanged) { var(modifier, key) = IsUsingController ? (ModifierButton.GetInstructionalKey(), SpawnCarButton.GetInstructionalKey()) : (ModifierKey.GetInstructionalKey(), SpawnCarKey.GetInstructionalKey()); spawnCarGroup.Buttons[0] = modifier; spawnCarGroup.Buttons[2] = key; instructional.Update(); } instructional.Draw(); bool spawn = IsUsingController ? (ModifierButton == ControllerButtons.None || Game.IsControllerButtonDownRightNow(ModifierButton)) && Game.IsControllerButtonDown(SpawnCarButton) : (ModifierKey == Keys.None || Game.IsKeyDownRightNow(ModifierKey)) && Game.IsKeyDown(SpawnCarKey); if (spawn) { GameFiber.StartNew(() => new Vehicle(m => m.IsCar, Game.LocalPlayer.Character.GetOffsetPositionFront(5.0f)).Dismiss()); } } }
void setKeyState(ModifierKey modifier, int keyValue) { setKeyState((modifier & ModifierKey.Ctrl) != 0, (modifier & ModifierKey.Alt) != 0, (modifier & ModifierKey.Shift) != 0, keyValue ); }
private static void CatchGlobalKeyEvents(Event current) { if (current.type != EventType.KeyUp) { return; } ModifierKey modifier = ExtShortCutEditor.GetModifierKey(UnityEssentialsPreferences.SHORTCUT_MODIFIER_KEY_FOR_PREVIOUS_NEXT_SELECTION, (int)UnityEssentialsPreferences.DEFAULT_MODIFIER_KEY); KeyCode previousKey = ExtShortCutEditor.GetKey(UnityEssentialsPreferences.SHORTCUT_KEY_FOR_PREVIOUS_SELECTION, (int)UnityEssentialsPreferences.DEFAULT_PREVIOUS_KEY); KeyCode nextKey = ExtShortCutEditor.GetKey(UnityEssentialsPreferences.SHORTCUT_KEY_FOR_NEXT_SELECTION, (int)UnityEssentialsPreferences.DEFAULT_NEXT_KEY); bool shortCutPrevious = ExtShortCutEditor.IsModifierEnumMatch(Event.current, modifier) && current.keyCode == previousKey; bool shortCutNext = ExtShortCutEditor.IsModifierEnumMatch(Event.current, modifier) && current.keyCode == nextKey; if (shortCutPrevious) { if (Selection.objects.Length != 0) { AddToIndex(-1); } ForceSelection(PeekSerializeObject.SelectedObjectsIndex(PeekSerializeObject.CurrentIndex)); } else if (shortCutNext) { AddToIndex(1); ForceSelection(PeekSerializeObject.SelectedObjectsIndex(PeekSerializeObject.CurrentIndex)); } }
public void RegisterHotKey(ModifierKey modifier, Keys key) { _currentId = _currentId + 1; if (!RegisterHotKey(_window.Handle, _currentId, (uint)modifier, (uint)key)) { throw new InvalidOperationException("Couldn’t register the hot key."); } }
public async Task <Modifier> Modifier(ModifierKey modKey) { var modCategory = await factory.ModCategories().Category(record.ModCategoryID); var modifier = await modCategory.Modifier(modKey); return(modifier); }
public async Task ShouldThrowError_WhenModifierIsNotFound(TModel model) { var adminUser = await tester.AdminUser(); var modKey = new ModifierKey("NotFound"); Assert.ThrowsAsync <AccessDeniedException>(() => tester.Execute(model, adminUser, modKey)); }
#pragma warning restore IDE0032 // Use auto property #pragma warning restore IDE0044 // Add readonly modifier /// <summary> /// Initializes a new instance of the <see cref="KeyEventArgs"/> class. /// </summary> /// <param name="key">The key that was pressed.</param> /// <param name="extension">The extension key that was pressed.</param> /// <param name="modifier">The single modifier that was pressed</param> /// <param name="modifiers">The multiple modifier keys that were pressed.</param> /// <param name="up">Whether the key was released or not.</param> public KeyEventArgs(char key, ExtensionKey extension, ModifierKey modifier, ModifierKey modifiers, bool up) { this.key = key; this.extension = extension; this.modifier = modifier; this.modifiers = modifiers; this.up = up; }
/// <summary> /// Initializes a new instance of the <see cref="KeyEventArgs"/> class. /// </summary> /// <param name="key">The key that was pressed.</param> /// <param name="ext">The extension key that was pressed.</param> /// <param name="modifier">The single modifier that was pressed</param> /// <param name="modifiers">The modifier keys that were pressed.</param> /// <param name="up">Whether the key was released or not.</param> public KeyEventArgs(string key, ExtensionKey ext, ModifierKey modifier, ModifierKey modifiers, bool up) { Key = key; Extension = ext; Modifier = modifier; Modifiers = modifiers; Up = up; }
protected void UpdateStoreValue(ModifierKey newValue) { if (!newValue.Equals(storeValue.Value)) // value changed // Store new value { storeValue.Value = newValue; } }
public void SetShortcut(ModifierKey modifier, Key key) { NSEventModifierFlags nsModifier = KeyMapper.GetModifier(modifier); string mappedKey = KeyMapper.GetKey(key); ObjC.Call(Handle, "setKeyEquivalentModifierMask:", new UIntPtr((ulong)nsModifier)); ObjC.Call(Handle, "setKeyEquivalent:", NSString.Create(mappedKey)); }
public int RegisterHotKey(ModifierKey modifier, Keys realKey) { _currentId++; if (!RegisterHotKey(_window.Handle, _currentId, (uint)modifier, (uint)realKey)) { throw new InvalidOperationException("Could not register the hot key."); } return _currentId; }
/// <summary> /// /// </summary> /// <param name="evt"></param> /// <param name="vk">If this is a keyboard trigger, then vk is the virtual code. If this is a mouse trigger, it is the integer value of the MouseButtons enum.</param> /// <param name="modifiers"></param> /// <param name="processName"></param> /// <param name="winRect"></param> public Trigger(TriggerType evt, int vk, ModifierKey modifiers, string[] processName, Rectangle winRect) { this.triggeredBy = evt; this.vk = vk; this.modifiers = modifiers; this.processName = new HashSet <string>(processName, StringComparer.OrdinalIgnoreCase); this.winRect = winRect; }
private void txtALT_MouseDown(object sender, MouseEventArgs e) { _modifier ^= ModifierKey.Alt; setKeyState((_modifier & ModifierKey.Ctrl) != 0, (_modifier & ModifierKey.Alt) != 0, (_modifier & ModifierKey.Shift) != 0, _vk); }
/// <summary> /// Adds a ActionKey to the list. /// </summary> /// <param name="key">The key that invokes the action.</param> /// <param name="callback">The callback function that should be called when the action key comes down.</param> /// <param name="modifierKeys">A list of modifier keys that must be pressed to fire callback.</param> /// <param name="once">Fires only once for key down, the key has to be released and pressed again to fire the callback again.</param> public void AddActionKey(VirtualKey key, ActionKeyHandler callback, ModifierKey[] modifierKeys = null, bool once = false) { if (mActionKeys.ContainsKey(key)) mActionKeys[key].Add(new ActionKeyInfo(key, callback, modifierKeys)); else mActionKeys.Add(key, new List<ActionKeyInfo>(new ActionKeyInfo[] { new ActionKeyInfo(key, callback, modifierKeys, once) })); }
internal KeyPressedEventArgs(ModifierKey modifier, Keys key) { KeyInfo = SVNMonitor.Helpers.KeyInfo.GetKeyInfo(modifier, key); }
void HandleButton(string button, bool newState) { bool isModifier = IgnoreKeys.Contains(button); if (EnableIgnoreModifiers && isModifier) return; if (LastState[button] && newState) return; if (!LastState[button] && !newState) return; //apply //NOTE: this is not quite right. if someone held leftshift+rightshift it would be broken. seems unlikely, though. if (button == "LeftShift") { _Modifiers &= ~ModifierKey.Shift; if (newState) _Modifiers |= ModifierKey.Shift; } if (button == "RightShift") { _Modifiers &= ~ModifierKey.Shift; if (newState) _Modifiers |= ModifierKey.Shift; } if (button == "LeftControl") { _Modifiers &= ~ModifierKey.Control; if (newState) _Modifiers |= ModifierKey.Control; } if (button == "RightControl") { _Modifiers &= ~ModifierKey.Control; if (newState) _Modifiers |= ModifierKey.Control; } if (button == "LeftAlt") { _Modifiers &= ~ModifierKey.Alt; if (newState) _Modifiers |= ModifierKey.Alt; } if (button == "RightAlt") { _Modifiers &= ~ModifierKey.Alt; if (newState) _Modifiers |= ModifierKey.Alt; } if (UnpressState.ContainsKey(button)) { if (newState) return; Console.WriteLine("Removing Unpress {0} with newState {1}", button, newState); UnpressState.Remove(button); LastState[button] = false; return; } //dont generate events for things like Ctrl+LeftControl ModifierKey mods = _Modifiers; if (button == "LeftShift") mods &= ~ModifierKey.Shift; if (button == "RightShift") mods &= ~ModifierKey.Shift; if (button == "LeftControl") mods &= ~ModifierKey.Control; if (button == "RightControl") mods &= ~ModifierKey.Control; if (button == "LeftAlt") mods &= ~ModifierKey.Alt; if (button == "RightAlt") mods &= ~ModifierKey.Alt; var ie = new InputEvent { EventType = newState ? InputEventType.Press : InputEventType.Release, LogicalButton = new LogicalButton(button, mods) }; LastState[button] = newState; //track the pressed events with modifiers that we send so that we can send corresponding unpresses with modifiers //this is an interesting idea, which we may need later, but not yet. //for example, you may see this series of events: press:ctrl+c, release:ctrl, release:c //but you might would rather have press:ctr+c, release:ctrl+c //this code relates the releases to the original presses. //UPDATE - this is necessary for the frame advance key, which has a special meaning when it gets stuck down //so, i am adding it as of 11-sep-2011 if (newState) { ModifierState[button] = ie.LogicalButton; } else { if (ModifierState[button] != null) { LogicalButton alreadyReleased = ie.LogicalButton; var ieModified = new InputEvent { LogicalButton = (LogicalButton)ModifierState[button], EventType = InputEventType.Release }; if (ieModified.LogicalButton != alreadyReleased) _NewEvents.Add(ieModified); } ModifierState[button] = null; } _NewEvents.Add(ie); }
/// <summary> /// Creates a new instance of the ActionKeyInfo class. /// </summary> /// <param name="actionKey">The key that invokes the action.</param> /// <param name="callback">The callback function that should be called when the action key comes down.</param> /// <param name="modifierKeys">A list of modifier keys that must be pressed to fire callback.</param> /// <param name="once">Fires only once for key down, the key has to be released and pressed again to fire the callback again.</param> public ActionKeyInfo(VirtualKey actionKey, ActionKeyHandler callback, ModifierKey[] modifierKeys = null, bool once = false) { mActionKey = actionKey; mModifierKeys = modifierKeys; mCallBack = callback; mOnce = once; ControlKeysState = new ControlKeysState(); }
/// <summary> /// Add a ActionKey CallbackFunction binding to the backup TreeViewAdv. /// </summary> /// <param name="key">The action key that raises the callback.</param> /// <param name="callback">The callback function with the action that should be called.</param> /// <param name="modifierKeys">Required state of the modifier keys to get the callback function called.</param> /// <param name="once">Flag to determine if the callback function should only be called once.</param> public void AddActionKey(VirtualKey key, ActionKeyHandler callback, ModifierKey[] modifierKeys = null, bool once = false) { tvParts.AddActionKey(key, callback, modifierKeys, once); }
private bool IsModifier(ModifierKey key) { return ((Modifier & key) != ModifierKey.None); }
public static KeyInfo GetKeyInfo(ModifierKey modifier, Keys realKey) { SVNMonitor.Helpers.Key key = EnumHelper.ParseEnum<SVNMonitor.Helpers.Key>(realKey.ToString()); return GetKeyInfo(modifier, key); }
public static KeyInfo GetKeyInfo(ModifierKey modifier, SVNMonitor.Helpers.Key key) { if ((modifier == ModifierKey.None) || (key == SVNMonitor.Helpers.Key.None)) { return None; } return new KeyInfo { Modifier = modifier, Key = key }; }
public LogicalButton(string button, ModifierKey modifiers) { Button = button; Modifiers = modifiers; }