Esempio n. 1
0
        private void KeyboardHook_KeyEvented(Keys key, KeyEventType type)
        {
            if (key == Keys.F9 && Control.ModifierKeys != Keys.Shift && type == KeyEventType.DOWN) // F9를 눌렀을 때
            {
                if (this.Visible)
                    Hide();
            }
            else if (key == Keys.F9 && Control.ModifierKeys == Keys.Shift && type == KeyEventType.DOWN) // Shift F9를 눌렀을 때
            {
                if (!this.Visible)
                {
                    Show();
                }
            }

            if (!isStart) return;
            if (key == Keys.Space && type == KeyEventType.DOWN)
                isPressingAlt = true;
            if (key == Keys.Space && type == KeyEventType.UP)
                isPressingAlt = false;
            if (isPressingAlt)
            {
                MouseHook.MakeMouseEvent(MouseEventType.SCROLLDOWN, MouseType.WHEEL, new Point());
                MouseHook.MakeMouseEvent(MouseEventType.SCROLLDOWN, MouseType.WHEEL, new Point());
                MouseHook.MakeMouseEvent(MouseEventType.SCROLLDOWN, MouseType.WHEEL, new Point());
                MouseHook.MakeMouseEvent(MouseEventType.SCROLLDOWN, MouseType.WHEEL, new Point());
                MouseHook.MakeMouseEvent(MouseEventType.SCROLLDOWN, MouseType.WHEEL, new Point());
                MouseHook.MakeMouseEvent(MouseEventType.SCROLLDOWN, MouseType.WHEEL, new Point());
                MouseHook.MakeMouseEvent(MouseEventType.SCROLLDOWN, MouseType.WHEEL, new Point());
            }
        }
Esempio n. 2
0
 public KeyEvent()
 {
     KeyChar = '\0';
     Key = ConsoleKeyEx.NoName;
     this.Modifiers = (ConsoleModifiers)0;
     Type = KeyEventType.Make;
 }
Esempio n. 3
0
 protected void OnKeyboardAction(object oSender, char?key, KeyEventType eventType)
 {
     Logic = Logic ?? throw new Exception($"{nameof(OnKeyboardAction)} in {nameof(CocoJumperBaseCommand)}, {nameof(Logic)} is null");
     if (Logic.KeyboardAction(key, eventType) == CocoJumperKeyboardActionResult.Finished)
     {
         CleanupLogicAndInputListener();
     }
 }
Esempio n. 4
0
 public void DoKeyEvent(KeyEventCode code, KeyEventType type)
 {
     if (keyValuePairs.ContainsKey(code))
     {
         var key = keyValuePairs[code];
         key.type = type;
     }
 }
Esempio n. 5
0
 public void RemoveEvent(T userCommand, KeyEventType keyEventType, Action <GameTime> action)
 {
     if (sourceActions.TryGetValue(action, out List <Action <UserCommandArgs, GameTime> > commandList) && commandList.Count > 0)
     {
         configurableUserCommands[userCommand, keyEventType] -= commandList[0];
         commandList.RemoveAt(0);
     }
 }
Esempio n. 6
0
 private void KeyboardHook_KeyEvented(Keys key, KeyEventType type)
 {
     if (isRecording)
     {
         KeyEvent eve = new KeyEvent(elapsed, key, type);
         AddEvent(eve);
     }
 }
Esempio n. 7
0
 internal KeyEventData(KeyEventType type, Keys key, ModKeyMask mask, float time)
 {
     Type      = type;
     Key       = key;
     Mods      = mask;
     EventTime = time;
     Timestamp = (float)AppTime.Elapsed.TotalSeconds;
 }
Esempio n. 8
0
 internal KeyEventData(KeyEventType type, Keys key, ModKeyMask mods, float et)
 {
     Type      = type;
     Key       = key;
     Mods      = mods;
     EventTime = et;
     Timestamp = Time.Elapsed;
 }
Esempio n. 9
0
 private void KeyboardHook_KeyEvented(Keys key, KeyEventType type)
 {
     if(isRecording)
     {
         KeyEvent eve = new KeyEvent(elapsed, key, type);
         AddEvent(eve);
     }
 }
Esempio n. 10
0
 public KeyEventData(KeyEventType eventType, TimeSpan time, int frame, InputFlags flags, Keys key)
 {
     EventType = eventType;
     Time      = time;
     Frame     = frame;
     Flags     = flags;
     Key       = key;
     Character = (char)0;
 }
Esempio n. 11
0
        public static KeyEventArgs ToEto(this swi.KeyEventArgs e, KeyEventType keyType)
        {
            var key = e.Key.ToEtoWithModifier(swi.Keyboard.Modifiers);

            return(new KeyEventArgs(key, keyType)
            {
                Handled = e.Handled
            });
        }
Esempio n. 12
0
 public KeyboardEvent(KeyEventType eventType, 
     Keyboard.VirtualKeyCodes keyData, 
     int aKeyFlags, char aChar)
 {
     fEventType = eventType;
     fKeyData = keyData;
     fKeyFlags = aKeyFlags;
     fKeyChar = aChar;
 }
Esempio n. 13
0
        private CocoJumperKeyboardActionResult PerformChoosing(char?key, KeyEventType eventType)
        {
            switch (eventType)
            {
            case KeyEventType.Backspace when _isSingleSearch:
                _state        = CocoJumperState.Searching;
                _searchString = string.Empty;
                _searchResults.Clear();
                RaiseRenderSearcherEvent();
                break;

            case KeyEventType.Backspace when !string.IsNullOrEmpty(_choosingString):
                _choosingString = RemoveLastChar(_choosingString);
                break;

            case KeyEventType.KeyPress when key.HasValue:
                char keyValue = GeyKeyValue(key);
                if (_searchResults
                    .Any(x => x.Key.ToLower().StartsWith(_choosingString + keyValue)))
                {
                    _choosingString += keyValue;
                }
                break;

            case KeyEventType.KeyPress:
                ThrowKeyPressWithNullKeyException();
                break;
            }

            SearchResult isFinished =
                _searchResults
                .SingleOrDefault(x => x.Key.ToLower() == _choosingString);

            if (isFinished != null)
            {
                if (_isHighlight)
                {
                    int caretPosition = _viewProvider.GetCaretPosition();
                    int toPosition    = caretPosition < isFinished.Position
                        ? isFinished.Position + 1
                        : isFinished.Position;
                    _viewProvider.MoveCaretTo(toPosition);
                    _viewProvider.SelectFromTo(caretPosition, toPosition);
                }
                else
                {
                    _viewProvider.MoveCaretTo(_jumpAfterChosenElement ? isFinished.Position + isFinished.Length : isFinished.Position);
                }
                _state = CocoJumperState.Inactive;
                RaiseExitEvent();

                return(CocoJumperKeyboardActionResult.Finished);
            }
            RaiseRenderSearcherEvent();
            RaiseSearchResultChangedEventWithFilter();
            return(CocoJumperKeyboardActionResult.Ok);
        }
Esempio n. 14
0
 /// <summary>
 /// Returns KeyEventArgs built with the provided parameters
 /// </summary>
 public static KeyEventArgsDg GetKeyEventArgs(KeyEventType eventType, char keyChar, int keyData, bool handled, bool suppressKeyPress)
 {
     keyEventArgs.SetEventType(eventType);
     keyEventArgs.SetKeyChar(keyChar);
     keyEventArgs.SetKeyData(keyData);
     keyEventArgs.Handled          = handled;
     keyEventArgs.SuppressKeyPress = suppressKeyPress;
     return(keyEventArgs);
 }
Esempio n. 15
0
 public KeyEventData(KeyEventType eventType, TimeSpan time, int frame, InputFlags flags, char character)
 {
     EventType = eventType;
     Time      = time;
     Frame     = frame;
     Flags     = flags;
     Key       = Keys.None;
     Character = character;
 }
        public void RemoveKeyEvent(Keys key, KeyModifiers modifiers, KeyEventType keyEventType, KeyEvent eventHandler)
        {
            int lookupCode = KeyEventCode(key, modifiers, keyEventType);

            if (keyEvents.ContainsKey(lookupCode))
            {
                keyEvents[lookupCode] -= eventHandler;
            }
        }
Esempio n. 17
0
        public static KeyEventArgs ToEto(this swi.KeyEventArgs e, KeyEventType keyType)
        {
            var key = KeyMap.Convert(e.Key, swi.Keyboard.Modifiers);

            return(new KeyEventArgs(key, keyType)
            {
                Handled = e.Handled
            });
        }
    /// <summary>
    /// Checks if the player has pressed any movement keys
    /// </summary>
    /// <param name="keyEventType">Key event to check for like down, up or hold</param>
    public static bool IsMovementPressed(KeyEventType keyEventType = KeyEventType.Down)
    {
        if (UIManager.IsInputFocus)
        {
            return(false);
        }

        return(Instance.CheckKeyAction(KeyAction.MoveUp, keyEventType) || Instance.CheckKeyAction(KeyAction.MoveDown, keyEventType) ||
               Instance.CheckKeyAction(KeyAction.MoveLeft, keyEventType) || Instance.CheckKeyAction(KeyAction.MoveRight, keyEventType));
    }
        public static void Call(KeyEventType evt)
        {
            if (KeyboardEventCalled == null)
            {
                return;
            }

            // TODO: make this so that there can be more than 1 subscriber, and that only the 'active' subscriber can take the key

            KeyboardEventCalled(evt);
        }
Esempio n. 20
0
        public static string MakeKeyLog(GlobalKeyEventArgs e, KeyEventType keyEventType)
        {
            bool ModifierKeyPressed = false;

            StringBuilder logMessage = new StringBuilder("Keyboard: "); //Start creating our text

            switch (keyEventType)                                       //Check which event called this method and set the appropriate text for it. The calling method passed on the event type to us via keyEventType argument.
            {
            case KeyEventType.OnKeyDown:
                logMessage.Append(e.KeyCode + " key has been pressed. ");
                break;

            case KeyEventType.OnKeyPress:
                logMessage.Append(e.KeyCode + " key is still being pressed. ");
                break;

            default:
                logMessage.Append(e.KeyCode + " key has been released. ");
                break;
            }

            //Check if the resulting character is set to something or not (e.g. CharResult would be empty if the user presses Shift on it's own.)
            if (!string.IsNullOrWhiteSpace(e.CharResult))
            {
                logMessage.Append(" Resulting Character: " + e.CharResult + " -- ");
            }

            logMessage.Append("[Modifier Key(s) Pressed: ");

            //Let's check which modifier keys are being pressed and append it to the log.
            if (e.Control != ModifierKeySide.None)
            {
                ModifierKeyPressed = true;
                logMessage.Append(e.Control.ToString() + " Control");
            }
            if (e.Shift != ModifierKeySide.None)
            {
                logMessage.Append((ModifierKeyPressed ? ", " : "") + e.Shift.ToString() + " Shift");
                ModifierKeyPressed = true;
            }
            if (e.Alt != ModifierKeySide.None)
            {
                logMessage.Append((ModifierKeyPressed ? ", " : "") + e.Alt.ToString() + " Alt");
                ModifierKeyPressed = true;
            }

            //If no modifier key was pressed, we append 'None' to the log to indicate that there was no modifier key being pressed.
            if (!ModifierKeyPressed)
            {
                logMessage.Append("None");
            }
            logMessage.Append("]");
            return(logMessage.ToString()); //Build the log text and return it to the calling method.
        }
Esempio n. 21
0
 private void NotifyInputService(KeyEventType complexEventType, Key key)
 {
     inputService.OnInputEvent(new KeyEventArgs
     {
         ComplexEventType = complexEventType,
         KeyModifyers     = GetKeyModifyersFromInput(),
         EventKey         = key,
         HasFocus         = true,
         State            = new KeyboardState(keys.Copy()),
         Viewport         = guiLazy.Value.RenderControl.Viewports.Single()
     });
 }
Esempio n. 22
0
        public static void SendKeys(ModifierKeys modifierKeys, VKeys[] keys, KeyEventType eventType)
        {
            Assert.ParamIsNotNull(keys);

            List <INPUT> inputBuffer = new List <INPUT>();

            if (eventType == KeyEventType.Down)
            {
                // Key down events
                if (Library.IsFlagSet(modifierKeys, Bespoke.Common.ModifierKeys.Shift))
                {
                    inputBuffer.Add(CreateKeyEvent(VKeys.SHIFT, KeyEventType.Down));
                }
                if (Library.IsFlagSet(modifierKeys, Bespoke.Common.ModifierKeys.Control))
                {
                    inputBuffer.Add(CreateKeyEvent(VKeys.CONTROL, KeyEventType.Down));
                }
                if (Library.IsFlagSet(modifierKeys, Bespoke.Common.ModifierKeys.Alt))
                {
                    inputBuffer.Add(CreateKeyEvent(VKeys.MENU, KeyEventType.Down));
                }
                foreach (VKeys key in keys)
                {
                    inputBuffer.Add(CreateKeyEvent(key, KeyEventType.Down));
                }
            }
            else
            {
                // Add key up events
                foreach (VKeys key in keys)
                {
                    inputBuffer.Add(CreateKeyEvent(key, KeyEventType.Up));
                }
                if (Library.IsFlagSet(modifierKeys, Bespoke.Common.ModifierKeys.Alt))
                {
                    inputBuffer.Add(CreateKeyEvent(VKeys.MENU, KeyEventType.Up));
                }
                if (Library.IsFlagSet(modifierKeys, Bespoke.Common.ModifierKeys.Control))
                {
                    inputBuffer.Add(CreateKeyEvent(VKeys.CONTROL, KeyEventType.Up));
                }
                if (Library.IsFlagSet(modifierKeys, Bespoke.Common.ModifierKeys.Shift))
                {
                    inputBuffer.Add(CreateKeyEvent(VKeys.SHIFT, KeyEventType.Up));
                }
            }

            if (inputBuffer.Count > 0)
            {
                INPUT[] buffer = inputBuffer.ToArray();
                SendInput((uint)buffer.Length, buffer, Marshal.SizeOf(buffer[0]));
            }
        }
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value == null || parameter == null)
            {
                return(null);
            }

            KeyEventType keyEventType = (KeyEventType)value;
            int          paramInt     = int.Parse(parameter.ToString());

            return((int)keyEventType == paramInt);
        }
Esempio n. 24
0
 /// <summary>
 /// Checks if the player has pressed any movement keys
 /// </summary>
 /// <param name="keyEventType">Key event to check for like down, up or hold</param>
 public static bool IsMovementPressed(KeyEventType keyEventType = KeyEventType.Down)
 {
     if (Instance.CheckKeyAction(KeyAction.MoveUp, keyEventType) || Instance.CheckKeyAction(KeyAction.MoveDown, keyEventType) ||
         Instance.CheckKeyAction(KeyAction.MoveLeft, keyEventType) || Instance.CheckKeyAction(KeyAction.MoveRight, keyEventType))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
    //Function that tries to get and fire a event regardless wheter the key is pressed or released
    private void OnKey(KeyCode key, KeyEventType eventType)
    {
        GeneralKeyEvent E = null;

        if (generalKeyEvents.TryGetValue(key, out E))
        {
            if (E != null)
            {
                E(key, eventType);
            }
        }
    }
Esempio n. 26
0
 internal void Trigger(T command, KeyEventType keyEventType, UserCommandArgs commandArgs, GameTime gameTime)
 {
     for (int i = 0; i < (layeredControllers?.Count ?? 0); i++)
     {
         layeredControllers[i].Trigger(command, keyEventType, commandArgs, gameTime);
         if (commandArgs.Handled)
         {
             return;
         }
     }
     configurableUserCommands[command, keyEventType]?.Invoke(commandArgs, gameTime);
 }
Esempio n. 27
0
        private void UpdateKeyState(KeyEventType complexEventType, Key key)
        {
            switch (complexEventType)
            {
            case KeyEventType.Down:
                keys[(int)key] = true;
                break;

            case KeyEventType.Up:
                keys[(int)key] = false;
                break;
            }
        }
Esempio n. 28
0
        private static INPUT CreateKeyEvent(VKeys key, KeyEventType eventType)
        {
            INPUT keyEvent = new INPUT();

            keyEvent.type           = INPUT_KEYBOARD;
            keyEvent.ki.wVk         = (ushort)key;
            keyEvent.ki.wScan       = 0;
            keyEvent.ki.dwFlags     = (uint)eventType;
            keyEvent.ki.time        = 0;
            keyEvent.ki.dwExtraInfo = (IntPtr)0;

            return(keyEvent);
        }
Esempio n. 29
0
    /// <summary>
    /// Check if either of the key combos for the selected action have been pressed
    /// </summary>
    /// <param name="keyAction">The action to check</param>
    /// <param name="keyEventType">The type of key event to check for</param>
    private bool CheckKeyAction(KeyAction keyAction, KeyEventType keyEventType = KeyEventType.Down)
    {
        KeybindObject action = keybindManager.userKeybinds[keyAction];

        if (CheckComboEvent(action.PrimaryCombo, keyEventType) || CheckComboEvent(action.SecondaryCombo, keyEventType))
        {
            return(true);
        }
        else
        {
            return(false);
        }
    }
Esempio n. 30
0
 //Translates an ATTACK key event to the target player
 private void OnAttackInput(KeyEventType type)
 {
     //If the target is valid
     if (target != null)
     {
         //If the event is a key down event
         if (type == KeyEventType.DOWN)
         {
             //Send attack event
             target.Attack();
         }
     }
 }
Esempio n. 31
0
        public void FullKeyHandler(object sender, KeyEventType keyEventType, IntPtr wParam, IntPtr lParam)
        {
            if (!Browser.IsBrowserInitialized || _browserHost == null || Browser.IsLoading)
            {
                return;
            }

            KeyEvent ke = new KeyEvent {
                Type = keyEventType, WindowsKeyCode = (int)wParam, Modifiers = GetModifiers()
            };

            _browserHost.SendKeyEvent(ke);
        }
Esempio n. 32
0
        public CocoJumperKeyboardActionResult KeyboardAction(char?key, KeyEventType eventType)
        {
            _autoExitDispatcherTimer.Stop();
            _autoExitDispatcherTimer.Start();
            if (eventType != KeyEventType.Cancel)
            {
                return(_state == CocoJumperState.Searching
                    ? PerformSearching(key, eventType)
                    : PerformChoosing(key, eventType));
            }

            RaiseExitEvent();
            return(CocoJumperKeyboardActionResult.Finished);
        }
        private static void OnKeyboardEventCalled(KeyEventType type)
        {
            switch (type)
            {
            case KeyEventType.HalfGridSizeKey:                      CSGSceneBottomGUI.MultiplySnapDistance(0.5f); break;

            case KeyEventType.DoubleGridSizeKey:            CSGSceneBottomGUI.MultiplySnapDistance(2.0f); break;

            // TODO: turn this into utility functions that are shared with CSGSceneBottomGUI
            case KeyEventType.ToggleBoundsSnappingKey:      CSGEditorSettings.PivotSnapping = !CSGEditorSettings.PivotSnapping; CSGEditorSettings.Save(); break;

            case KeyEventType.TogglePivotSnappingKey:       CSGEditorSettings.BoundsSnapping = !CSGEditorSettings.BoundsSnapping; CSGEditorSettings.Save(); break;

            case KeyEventType.ToggleShowGridKey:            CSGEditorSettings.ShowGrid = !CSGEditorSettings.ShowGrid; CSGEditorSettings.Save(); break;
            }
        }
Esempio n. 34
0
        public static KeyEventArgs ToEto(this Gdk.EventKey args)
        {
            Keys key = args.Key.ToEto() | args.State.ToEtoKey();

            KeyEventType keyEventType = args.Type == Gdk.EventType.KeyRelease ? KeyEventType.KeyUp : KeyEventType.KeyDown;

            if (key != Keys.None)
            {
                Keys modifiers = (key & Keys.ModifierMask);
                if (args.KeyValue <= 128 && ((modifiers & ~Keys.Shift) == 0))
                {
                    return(new KeyEventArgs(key, keyEventType, (char)args.KeyValue));
                }
                return(new KeyEventArgs(key, keyEventType));
            }
            return(args.KeyValue <= 128 ? new KeyEventArgs(key, keyEventType, (char)args.KeyValue) : null);
        }
Esempio n. 35
0
 public KeyEvent(char keyChar, ConsoleKeyEx key, bool shift, bool alt, bool control, KeyEventType type)
 {
     this.KeyChar = keyChar;
     this.Key = key;
     this.Modifiers = (ConsoleModifiers)0;
     if (shift)
     {
         this.Modifiers |= ConsoleModifiers.Shift;
     }
     if (alt)
     {
         this.Modifiers |= ConsoleModifiers.Alt;
     }
     if (control)
     {
         this.Modifiers |= ConsoleModifiers.Control;
     }
     this.Type = type;
 }
Esempio n. 36
0
        private void KeyboardHook_KeyEvented(Keys key, KeyEventType type)
        {
            if (key == Keys.F9 && Control.ModifierKeys != Keys.Shift && type == KeyEventType.DOWN) // F9를 눌렀을 때
            {
                if (this.Visible)
                    Hide();
            }
            else if (key == Keys.F9 && Control.ModifierKeys == Keys.Shift && type == KeyEventType.DOWN) // Shift F9를 눌렀을 때
            {
                if (!this.Visible)
                {
                    Show();
                }
            }

            if (!isStart) return;
            KeyEvents.Add(new KeyEvent(elapsed, key, type));

            //if (type == KeyEventType.DOWN)
                this.tbText.AppendText(key.ToString() + " ");
        }
 private bool IsKeyInState(Keys key, KeyEventType keyEventType)
 {
     switch (keyEventType)
     {
         case KeyEventType.Up:
             {
                 return IsKeyUp(key);
             }
         case KeyEventType.Down:
             {
                 return IsKeyDown(key);
             }
         case KeyEventType.Pressed:
             {
                 return IsKeyPressed(key);
             }
         default:
             {
                 return false;
             }
     }
 }
Esempio n. 38
0
        private void KeyHook_KeyEvented(Keys k, KeyEventType keyevent)
        {
            if (keyevent == KeyEventType.KEYDOWN)
            {
                if (hotKeyManager.isHotKeyed(k))
                {
                    SShot captured = hotKeyManager.CapturHotkeyed(k);
                    captured.CaptureSShot();
                }

                if (hotKeyManager.isHotKeyHotkeyed(k))
                {
                    HotKeyScreenShot captured = hotKeyManager.CaptureSetKeyed(k);
                    captured.SetRect();
                }

                if(hotKeyManager.isHandleHotKeyed(k))
                {
                    WindowScreenShot captured = hotKeyManager.CaptureHandleHotKeyed(k);
                    captured.SetWindowHandle();
                }
            }
        }
Esempio n. 39
0
 public KeyEvent(uint elapsed, Keys key, KeyEventType type) : base(EventType.KEYEVENT, elapsed)
 {
     this.Key = key;
     this.KeyEventType = type;
 }
 public KeyboardOutput(Keys key = Keys.A, KeyEventType eventType = KeyEventType.Tap)
 {
     this.Key = key;
     this.EventType = eventType;
 }
        /// <summary>
        /// Send an event for a set of keys.
        /// </summary>
        /// <param name="modifierKeys">Modifier keys associated with each key event.</param>
        /// <param name="keys">The associated keys.</param>
        /// <param name="eventType">The event type.</param>
        public static void SendKeys(ModifierKeys modifierKeys, VKeys[] keys, KeyEventType eventType)
        {
            Assert.ParamIsNotNull(keys);

            List<INPUT> inputBuffer = new List<INPUT>();

            if (eventType == KeyEventType.Down)
            {
                // Key down events
                if (Utility.IsFlagSet(modifierKeys, Bespoke.Common.ModifierKeys.Shift))
                {
                    inputBuffer.Add(CreateKeyEvent(VKeys.SHIFT, KeyEventType.Down));
                }
                if (Utility.IsFlagSet(modifierKeys, Bespoke.Common.ModifierKeys.Control))
                {
                    inputBuffer.Add(CreateKeyEvent(VKeys.CONTROL, KeyEventType.Down));
                }
                if (Utility.IsFlagSet(modifierKeys, Bespoke.Common.ModifierKeys.Alt))
                {
                    inputBuffer.Add(CreateKeyEvent(VKeys.MENU, KeyEventType.Down));
                }
                foreach (VKeys key in keys)
                {
                    inputBuffer.Add(CreateKeyEvent(key, KeyEventType.Down));
                }
            }
            else
            {
                // Add key up events
                foreach (VKeys key in keys)
                {
                    inputBuffer.Add(CreateKeyEvent(key, KeyEventType.Up));
                }
                if (Utility.IsFlagSet(modifierKeys, Bespoke.Common.ModifierKeys.Alt))
                {
                    inputBuffer.Add(CreateKeyEvent(VKeys.MENU, KeyEventType.Up));
                }
                if (Utility.IsFlagSet(modifierKeys, Bespoke.Common.ModifierKeys.Control))
                {
                    inputBuffer.Add(CreateKeyEvent(VKeys.CONTROL, KeyEventType.Up));
                }
                if (Utility.IsFlagSet(modifierKeys, Bespoke.Common.ModifierKeys.Shift))
                {
                    inputBuffer.Add(CreateKeyEvent(VKeys.SHIFT, KeyEventType.Up));
                }
            }

            if (inputBuffer.Count > 0)
            {
                INPUT[] buffer = inputBuffer.ToArray();
                SendInput((uint)buffer.Length, buffer, Marshal.SizeOf(buffer[0]));
            }
        }
 public KeyCombination(Keys key, KeyEventType keyEventType)
 {
     Keys = new List<KeyValuePair<Keys, KeyEventType>>();
     Keys.Add(new KeyValuePair<Keys, KeyEventType>(key, keyEventType));
 }
Esempio n. 43
0
 /// <summary>
 /// Returns KeyEventArgs built with the provided parameters
 /// </summary>
 public static KeyEventArgsDg GetKeyEventArgs(KeyEventType eventType, char keyChar, int keyData, bool handled, bool suppressKeyPress)
 {
     keyEventArgs.SetEventType(eventType);
     keyEventArgs.SetKeyChar(keyChar);
     keyEventArgs.SetKeyData(keyData);
     keyEventArgs.Handled = handled;
     keyEventArgs.SuppressKeyPress = suppressKeyPress;
     return keyEventArgs;
 }
Esempio n. 44
0
		static bool KeyEvent(BubbleEventArgs be, Action<Control, KeyEventArgs> action, KeyEventType keyEventType)
		{
			Keys keyData = ((swf.Keys)(long)be.Message.WParam | swf.Control.ModifierKeys).ToEto();
			
			char? keyChar = null;
			var kevt = new KeyEventArgs(keyData, keyEventType, keyChar);
			if (be.Control != null)
				action(be.Control, kevt);
			if (!kevt.Handled && (keyEventType != KeyEventType.KeyDown || !IsInputKey(be.Message.HWnd, keyData)))
			{
				foreach (var control in be.Parents)
				{
					action(control, kevt);
					if (kevt.Handled)
						break;
				}
			}
			return kevt.Handled;
		}
Esempio n. 45
0
 /// <ToBeCompleted></ToBeCompleted>
 protected internal KeyEventArgsDg()
 {
     this.eventType = KeyEventType.PreviewKeyDown;
     this.handled = false;
     this.keyChar = '\0';
     this.keyData = 0;
     this.suppressKeyPress = false;
 }
Esempio n. 46
0
		public static KeyEventArgs ToEto(this swi.KeyEventArgs e, KeyEventType keyType)
		{
			var key = e.Key.ToEtoWithModifier(swi.Keyboard.Modifiers);
			return new KeyEventArgs(key, keyType) { Handled = e.Handled };
		}
Esempio n. 47
0
		static bool KeyCharEvent(BubbleEventArgs be, Action<Control, KeyEventArgs> action, KeyEventType keyEventType)
		{
			Keys keyData = Keys.None;

			char keyChar = (char)((long)be.Message.WParam);
			var kevt = new KeyEventArgs(keyData, keyEventType, keyChar);
			if (be.Control != null)
				action(be.Control, kevt);
			if (!kevt.Handled && !IsInputChar(be.Message.HWnd, keyChar))
			{
				foreach (var control in be.Parents)
				{
					action(control, kevt);
					if (kevt.Handled)
						break;
				}
			}
			return kevt.Handled;
		}
        private static INPUT CreateKeyEvent(VKeys key, KeyEventType eventType)
        {
            INPUT keyEvent = new INPUT();
            keyEvent.type = INPUT_KEYBOARD;
            keyEvent.ki.wVk = (ushort)key;
            keyEvent.ki.wScan = 0;
            keyEvent.ki.dwFlags = (uint)eventType;
            keyEvent.ki.time = 0;
            keyEvent.ki.dwExtraInfo = (IntPtr)0;

            return keyEvent;
        }
 public KeyCombination(Keys key1, KeyEventType keyEventType1, Keys key2, KeyEventType keyEventType2, Keys key3, KeyEventType keyEventType3)
 {
     Keys = new List<KeyValuePair<Keys, KeyEventType>>();
     Keys.Add(new KeyValuePair<Keys, KeyEventType>(key1, keyEventType1));
     Keys.Add(new KeyValuePair<Keys, KeyEventType>(key2, keyEventType2));
     Keys.Add(new KeyValuePair<Keys, KeyEventType>(key3, keyEventType3));
 }
Esempio n. 50
0
		public static KeyEventArgs ToEto(this wuc.KeyEventArgs e, KeyEventType keyType)
		{
			var key = KeyMap.Convert(e.Key, swi.Keyboard.Modifiers);
			return new KeyEventArgs(key, keyType) { Handled = e.Handled };
		}
Esempio n. 51
0
 /// <summary>
 /// Extracts and returns KeyEventArgs from Windows.Forms.KeyEventArgs
 /// </summary>
 public static KeyEventArgsDg GetKeyEventArgs(KeyEventType eventType, KeyEventArgs e)
 {
     return GetKeyEventArgs(eventType, '\0', (int)e.KeyData, e.Handled, e.SuppressKeyPress);
 }
Esempio n. 52
0
		/// <summary>
		/// Initializes a new instance of the KeyPressEventArgs class for a character key press
		/// </summary>
		/// <param name="keyData">Key and modifiers that were pressed</param>
		/// <param name="keyEventType">Type of key event</param>
		/// <param name="keyChar">Character equivalent</param>
		public KeyPressEventArgs(Key keyData, KeyEventType keyEventType, char? keyChar = null)
		{
            this.KeyData = keyData;
			this.KeyEventType = keyEventType;
			this.keyChar = keyChar;
		}
Esempio n. 53
0
 public void SetEventType(KeyEventType eventType)
 {
     this.eventType = eventType;
 }
Esempio n. 54
0
		/// <summary>
		/// Initializes a new instance of the KeyPressEventArgs class for a character key press
		/// </summary>
		/// <param name="keyData">Key and modifiers that were pressed</param>
		/// <param name="keyEventType">Type of key event</param>
		/// <param name="keyChar">Character equivalent</param>
		public KeyEventArgs(Key keyData, KeyEventType keyEventType, char? keyChar = null)
			: base (keyData, keyEventType, keyChar)
		{
		}
Esempio n. 55
0
		public void AddBubbleKeyCharEvent(Action<Control, KeyEventArgs> action, Win32.WM message, KeyEventType keyEventType)
		{
			AddBubbleEvent(be => KeyCharEvent(be, action, keyEventType), message);
		}
Esempio n. 56
0
 public static void MakeKeyEvent(Keys key, KeyEventType type)
 {
     switch(type)
     {
         case KeyEventType.DOWN:
             keybd_event((byte)key, 0x00, 0x00, 0);
             break;
         case KeyEventType.UP:
             keybd_event((byte)key, 0x00, 0x02, 0);
             break;
         case KeyEventType.CLICK:
             keybd_event((byte)key, 0x00, 0x00, 0);
             keybd_event((byte)key, 0x00, 0x02, 0);
             break;
     }
 }
Esempio n. 57
0
		/// <summary>
		/// Initializes a new instance of <see cref="T:Dataweb.NShape.Controllers.KeyEventArgsDg" />.
		/// </summary>
		public KeyEventArgsDg(KeyEventType eventType, int keyData, char keyChar, bool handled, bool suppressKeyPress)
		{
			this.eventType = eventType;
			this.handled = handled;
			this.keyChar = keyChar;
			this.keyData = keyData;
			this.suppressKeyPress = suppressKeyPress;
		}
Esempio n. 58
0
		static bool KeyCharEvent(BubbleEventArgs be, Action<Control, Control.ICallback, KeyEventArgs> action, KeyEventType keyEventType)
		{
			char keyChar = (char)((long)be.Message.WParam);
			var kevt = new KeyEventArgs(Keys.None, keyEventType, keyChar);
			if (be.Control != null)
				action(be.Control, (Control.ICallback)((ICallbackSource)be.Control).Callback, kevt);
			if (!kevt.Handled && !IsInputChar(be.Message.HWnd, keyChar))
			{
				foreach (var control in be.Parents)
				{
					var callback = (Control.ICallback)((ICallbackSource)control).Callback;
					action(control, callback, kevt);
					if (kevt.Handled)
						break;
				}
			}
			return kevt.Handled;
		}