public KeyboardHookEventArgs(KeyboardEventType type, Keys key, int wParam, Native.keyboardHookStruct lParam) { Type = type; this.wParam = wParam; this.lParam = lParam; this.key = key; }
public InputEventKeyboard(KeyboardEventType eventType, WinKeys wParam_VirtKeyCode, int lParam_KeyData, WinKeys modifiers) : base(modifiers) { m_eventType = eventType; m_keyCode = wParam_VirtKeyCode; m_keyDataExtra = lParam_KeyData; }
public InputEventKeyboard(KeyboardEventType eventType, InputEventKeyboard parent) : base(parent) { m_eventType = eventType; m_keyCode = parent.m_keyCode; m_keyDataExtra = parent.m_keyDataExtra; }
public KeyboardEvent(KeyboardEventType type, bool shift, bool alt, bool ctrl) { this.type = type; this.shift = shift; this.alt = alt; this.ctrl = ctrl; }
protected override int HookCallback(int nCode, IntPtr wParam, IntPtr lParam) { if (nCode != 0) { return(HookExtern.CallNextHookEx(this.HookType, nCode, wParam, lParam)); } KeyboardEventType eventType = (KeyboardEventType)(((uint)wParam % 2) + 256); // filter out SysKeyDown & SysKeyUp Keys key = (Keys)Marshal.ReadInt32(lParam); KeyboardEventArgs KeyboardEventArgs = new KeyboardEventArgs(eventType, key); bool isHandled = false; lock (((IList)this.Handlers).SyncRoot) { foreach (HandleKeyboardInputDelegate handler in this.Handlers) { isHandled = handler(KeyboardEventArgs); if (isHandled) { break; } } } if (isHandled) { return(1); } else { return(HookExtern.CallNextHookEx(this.HookType, nCode, wParam, lParam)); } }
public override void KeyboardEvent(KeyboardEventType down, KeyEventArgs args) { var fr = Elements.FirstOrDefault(z => z.IsFocused); if (fr != null) { fr.KeyboardEvent(down, args); } }
protected void DispatchKeyboradEvent(KeyboardEventType keyboradEventType, VirtualKeys virtualKey) { if (!virtualKeyToKeyCodeMap.ContainsKey(virtualKey)) { Debug.LogWarningFormat("Unknown virtual key detected: {0}", virtualKey); return; } this.KeyboradEvent?.Invoke(new KeyboardEvent(keyboradEventType, virtualKeyToKeyCodeMap[virtualKey])); }
private IntPtr OnKeyboard(int nCode, IntPtr wParam, IntPtr lParam) { if (nCode >= 0 && (wParam == (IntPtr)WM_KEYDOWN || wParam == (IntPtr)WM_KEYUP)) { KeyboardEventType type = wParam == (IntPtr)WM_KEYDOWN ? KeyboardEventType.KeyDown : KeyboardEventType.KeyUp; Keys key = (Keys)Marshal.ReadInt32(lParam); this.KeyEvent?.Invoke(this, type, key); } return(CallNextHookEx(_hookID, nCode, wParam, lParam)); }
public KeyboardEventData(KeyboardEventType eventType, bool alt, bool control, Key keyCode, Key keyData, int keyValue, bool shift, char keyChar, DateTime timestamp) : base(timestamp) { EventType = eventType; Alt = alt; Control = control; KeyCode = keyCode; KeyData = keyData; KeyValue = keyValue; KeyChar = keyChar; Shift = shift; }
public static KeyEventF ToWindowsKeyEvent(this KeyboardEventType src) { switch (src) { case KeyboardEventType.KEY_DOWN: return(KeyEventF.KeyDown); case KeyboardEventType.KEY_UP: return(KeyEventF.KeyUp); } return(KeyEventF.ExtendedKey); }
/// <summary> /// Converts the keyboard event type, the key, and the modifier keys' information /// to an array of bytes so that it can be sent over the network. /// </summary> /// <param name="type">Press, Release, or Type</param> /// <param name="key">The key</param> /// <param name="modifier">A struct that indicates whether any of the modifier /// keys are held down</param> /// <returns></returns> public byte[] GetNetworkData(KeyboardEventType type, Keys key, KeyModifier modifier) { // 1 byte for type, 1 byte for key, and 1 (bool) * 3 bytes for modifier byte[] data = new byte[5]; data[0] = (byte)type; data[1] = (byte)key; data[2] = BitConverter.GetBytes(modifier.AltKeyPressed)[0]; data[3] = BitConverter.GetBytes(modifier.CtrlKeyPressed)[0]; data[4] = BitConverter.GetBytes(modifier.ShiftKeyPressed)[0]; return(data); }
public override void KeyboardEvent(KeyboardEventType down, KeyEventArgs args) { var a = (int)args.KeyCode; if (down == KeyboardEventType.Down) { press((byte)a); } if (down == KeyboardEventType.Up) { release((byte)a); } }
private void FireRawInputEvent(ref RawInput ri) { try { TraceLogger.Instance.WriteLineVerbos("FireRawInputEvent: " + ri.Header.dwType); switch (ri.Header.dwType) { case (int)RawInputType.Mouse: if (RawInputMouseEvent != null) { //if (Enum.IsDefined(typeof(MouseEventType), (short)(ri.Data.Mouse.ulButtons & ushort.MaxValue))) { MouseEventType evt = (MouseEventType)ri.Data.Mouse.ulButtons; int x = Cursor.Position.X; int y = Cursor.Position.Y; RawInputMouseEvent(evt, x, y); } //else { //TraceLogger.Instance.WriteLineInfo(string.Format("Undefined MouseEventType: {0:X}", ri.Data.Mouse.ulButtons)); } } break; case (int)RawInputType.KeyBoard: if (RawInputKeyboardEvent != null) { //if (Enum.IsDefined(typeof(KeyboardEventType), (short)ri.Data.Keyboard.Message)) { KeyboardEventType evt = (KeyboardEventType)ri.Data.Keyboard.Message; Keys key = (Keys)ri.Data.Keyboard.VKey; RawInputKeyboardEvent(evt, key); } //else { //TraceLogger.Instance.WriteLineInfo(string.Format("Undefined KeyboardEventType: {0:X}", ri.Data.Keyboard.Message)); } } break; default: break; } } catch (Exception ex) { TraceLogger.Instance.WriteException(ex); } }
void sendEvent(KeyCode keycode, KeyboardEventType evType) { if (evType == KeyboardEventType.keyDown) { OnKey.Invoke(keycode); } if (evType == KeyboardEventType.KeyUp) { OnKeyUp.Invoke(keycode); } if (evType == KeyboardEventType.down) { OnKeyDown.Invoke(keycode); } }
private bool ProcessInput(KeyboardEventType eventType, Keys key) { _inputBuffer.Enqueue(new KeyboardEventArgs(eventType, key)); if (_textInputDelegate != null) { string chars = TypedInputUtil.VkCodeToString((uint)key, eventType == KeyboardEventType.KeyDown); _textInputDelegate?.BeginInvoke(chars, EndTextInputAsyncInvoke, null); return(ShouldBlockKeyEvent(key)); } // TODO: Implement blocking based on the key that is pressed (for example: Key binding blocking the last pressed key) return(false); }
private bool ProcessInput(KeyboardEventType eventType, Keys key) { _inputBuffer.Enqueue(new KeyboardEventArgs(eventType, key)); if (_textInputDelegate != null) { string chars = TypedInputUtil.VkCodeToString((uint)key, eventType == KeyboardEventType.KeyDown); _textInputDelegate?.BeginInvoke(chars, EndTextInputAsyncInvoke, null); return(true /* key != Keys.LeftShift && key != Keys.RightShift */); // "SHIFT" support temporarily disabled } // TODO: Implement blocking based on the key that is pressed (for example: Key binding blocking the last pressed key) return(false); }
internal void ReceiveKeyboardEvent(KeyboardEventType ke) { switch (ke) { case KeyboardEventType.Down: m_InInitialRepeatPeriod = true; m_State = ActionState.Press; m_SecondsSincePress = 0f; break; case KeyboardEventType.Up: m_State = ActionState.Release; break; // ignore press events - we handle our own presses. } }
public void SendCharEvent(int character, KeyboardEventType type) { if (Initialized) { KeyboardEvent keyboardEvent = new KeyboardEvent { Type = type, Key = character }; EventPacket ep = new EventPacket { Event = keyboardEvent, Type = BrowserEventType.Keyboard }; _outCommServer.TrySend(ep, 100); } }
public void SendCharEvent(int character, KeyboardEventType type) { if (Initialized) { KeyboardEvent keyboardEvent = new KeyboardEvent() { Type = type, Key = character }; EventPacket ep = new EventPacket() { Event = keyboardEvent, Type = MessageLibrary.BrowserEventType.Keyboard }; _outCommServer.WriteMessage(ep); } }
public static void MakeKeyEvent(int vkCode, KeyboardEventType type) { switch (type) { case KeyboardEventType.KEYDOWN: keybd_event((byte)vkCode, 0x00, 0x00, 0); break; case KeyboardEventType.KEYUP: keybd_event((byte)vkCode, 0x00, 0x02, 0); break; case KeyboardEventType.KEYCLICK: keybd_event((byte)vkCode, 0x00, 0x00, 0); keybd_event((byte)vkCode, 0x00, 0x02, 0); break; } }
public static void MakeKeyEvent(Keys vkCode, KeyboardEventType type) { switch (type) { case KeyboardEventType.KEYDOWN: WinAPI.Keybd_event((byte)vkCode, 0x00, 0x00, 0); break; case KeyboardEventType.KEYUP: WinAPI.Keybd_event((byte)vkCode, 0x00, 0x02, 0); break; case KeyboardEventType.KEYCLICK: WinAPI.Keybd_event((byte)vkCode, 0x00, 0x00, 0); WinAPI.Keybd_event((byte)vkCode, 0x00, 0x02, 0); break; } }
private void OnKeyUpDownEvent(KeyboardEventType eventType, KeyEventArgs args) { DateTime timestamp; if (args is KeyEventArgsExt) { var argsExt = (KeyEventArgsExt)args; timestamp = _ticksConverter.Convert(argsExt.Timestamp); } else { timestamp = DateTime.Now; } var eventData = new KeyboardEventData(eventType, args.Alt, args.Control, (Key)args.KeyCode, (Key)args.KeyData, args.KeyValue, args.Shift, (char)0, timestamp); Data?.Invoke(this, eventData); }
public void KeyboardEvent(int character, KeyboardEventType type) { CefKeyEvent keyEvent = new CefKeyEvent() { EventType = CefKeyEventType.Char, WindowsKeyCode = character }; if (type == KeyboardEventType.Down) { keyEvent.EventType = CefKeyEventType.KeyDown; } if (type == KeyboardEventType.Up) { keyEvent.EventType = CefKeyEventType.KeyUp; } _lifespanHandler.MainBrowser.GetHost().SendKeyEvent(keyEvent); }
public override void KeyboardEvent(KeyboardEventType down, KeyEventArgs args) { if (down != KeyboardEventType.Up) { return; } if (args.KeyCode == Keys.Back) { if (Text.Length > 0) { Text = Text.Substring(0, Text.Length - 1); } } else { Text += args.KeyCode; } base.KeyboardEvent(down, args); }
public bool HandleKeyboardEvent(KeyboardEventType type, WinKeys key, bool shift, bool alt, bool ctrl) { foreach (InputEvent e in m_EventsThisFrame) { if (!e.Handled && e is InputEventKeyboard) { InputEventKeyboard ek = (InputEventKeyboard)e; if (ek.EventType == type && ek.KeyCode == key && ek.Shift == shift && ek.Alt == alt && ek.Control == ctrl) { e.Handled = true; return(true); } } } return(false); }
/// <summary> Adds an action that should occur when the key is down. </summary> /// <param name="type"> The type of keyboard event that causes the action to be invoked. </param> /// <param name="key"> The key that should be checked. </param> /// <param name="action"> The action to perform if the key is down. </param> public void Add(KeyboardEventType type, KeyCode key, Action action) { switch (type) { case KeyboardEventType.Down: _actions.Add(new KeyDownAction(key, action)); break; case KeyboardEventType.ToggleDown: _actions.Add(new KeyPressAction(key, action)); break; case KeyboardEventType.ToggleUp: _actions.Add(new KeyReleaseAction(key, action)); break; default: throw new ArgumentOutOfRangeException("type", type, null); } }
void ProcessKeyEvent(KeyboardEventType state, bool repeat, byte keyCode, char character) { switch (state) { case KeyboardEventType.KeyDown: if (!repeat) { InputSystem.QueueStateEvent(RemoteKeyboard, new KeyboardState((Key)keyCode)); } if (character != 0) { InputSystem.QueueTextEvent(RemoteKeyboard, character); } break; case KeyboardEventType.KeyUp: InputSystem.QueueStateEvent(RemoteKeyboard, new KeyboardState()); break; } }
public bool SnapshotOnKeyboardEvent(KeyboardEventType evt, Keys key) { bool snap = false; if (evt == KeyboardEventType.KeyDown) { if (key == Keys.Enter || key == Keys.Delete) { if (DateTime.Now.Subtract(_lastKeyTime).Milliseconds > 1000) { snap = true; } else { if (!_isLastEventFromKeyboard || key != _lastKeyValue) { snap = true; } } } else // General Key { if (!_isLastEventFromKeyboard && DateTime.Now.Subtract(_prevGeneralKeyTime).TotalMilliseconds > 1000) { snap = true; _prevGeneralKeyTime = DateTime.Now; } if (DateTime.Now.Subtract(_prevGeneralKeyTime).TotalMilliseconds > 10 * 1000) { snap = true; _prevGeneralKeyTime = DateTime.Now; } } _isLastEventFromKeyboard = true; _lastKeyTime = DateTime.Now; _lastKeyValue = key; } TraceLogger.Instance.WriteLineInfo("SnapshotOnKeyboardEvent: " + snap.ToString()); return(snap); }
void ProcessKeyEvent(KeyboardEventType state, bool repeat, byte keyCode, char character) { switch (state) { case KeyboardEventType.KeyDown: if (!repeat) { m_keyboardState.Set((Key)keyCode, true); UnityInputSystem.QueueStateEvent(RemoteKeyboard, m_keyboardState); } if (character != 0) { UnityInputSystem.QueueTextEvent(RemoteKeyboard, character); } break; case KeyboardEventType.KeyUp: m_keyboardState.Set((Key)keyCode, false); UnityInputSystem.QueueStateEvent(RemoteKeyboard, m_keyboardState); break; } }
public static void SendKey(KeyboardEventType type, KeyCode key) { #if WINDOWS_OS WindowInput[] inputs = new WindowInput[] { new WindowInput() { type = (int)WindowInputType.Keyboard, u = new WindowInputMessage() { ki = new WindowKeyboardInput() { wVk = 0, wScan = (ushort)key.ToScanCode(), dwFlags = (uint)(type.ToWindowsKeyEvent() | KeyEventF.Scancode), dwExtraInfo = GetMessageExtraInfo() } } } }; SendInput(1, inputs, Marshal.SizeOf <WindowInput>()); #endif }
internal KeyboardEvent(KeyboardEventType eventType, Key key, int platformKeyCode) { Key = key; PlatformKeyCode = platformKeyCode; EventType = eventType; }
/// <summary> /// Converts the keyboard event type, the key, and the modifier keys' information /// to an array of bytes so that it can be sent over the network. /// </summary> /// <param name="type">Press, Release, or Type</param> /// <param name="key">The key</param> /// <param name="modifier">A struct that indicates whether any of the modifier /// keys are held down</param> /// <returns></returns> public byte[] GetNetworkData(KeyboardEventType type, Keys key, KeyModifier modifier) { // 1 byte for type, 1 byte for key, and 1 (bool) * 3 bytes for modifier byte[] data = new byte[5]; data[0] = (byte)type; data[1] = (byte)key; data[2] = BitConverter.GetBytes(modifier.AltKeyPressed)[0]; data[3] = BitConverter.GetBytes(modifier.CtrlKeyPressed)[0]; data[4] = BitConverter.GetBytes(modifier.ShiftKeyPressed)[0]; return data; }
public bool HandleKeyboardEvent(KeyboardEventType type, WinKeys key, bool shift, bool alt, bool ctrl) { foreach(InputEvent e in m_EventsThisFrame) { if(!e.Handled && e is InputEventKeyboard) { InputEventKeyboard ek = (InputEventKeyboard)e; if(ek.EventType == type && ek.KeyCode == key && ek.Shift == shift && ek.Alt == alt && ek.Control == ctrl) { e.Handled = true; return true; } } } return false; }