private string PunchDataToText(byte[] punchData) { string text = ""; KeyStates keyStates = new KeyStates(ShiftStates.Ltr, ConfigManager.Instance.Config.CodeSet); foreach (byte code in punchData) { if (code == CodeManager.BAU_LTRS) { keyStates.ShiftState = ShiftStates.Ltr; } else if (code == CodeManager.BAU_FIGS) { keyStates.ShiftState = ShiftStates.Figs; } else { char ascii = CodeManager.BaudotCharToAscii(code, keyStates, CodeManager.SendRecv.Send); if (ascii != '\r') { text += ascii; } } } return(text); }
public bool IsKeyUp(Key key) { bool isInCurrent = KeyStates.TryGetValue(key, out var result); bool wasInPrevious = PreviousKeyStates.TryGetValue(key, out var prevResult); return(!result && prevResult || (!result && !prevResult)); }
public static bool SendKeyboardInput(Keys key, KeyStates state) { var inputEvent = new NativeInputEvent() { Type = NativeInputType.Keyboard }; inputEvent.KeyboardInput.Key = (ushort)key; if ((state & KeyStates.Toggled) == KeyStates.Toggled) { inputEvent.KeyboardInput.Flags = NativeKeyboardEventFlags.Down; if (User32.SendInput(1u, ref inputEvent, NativeInputEvent.Size) == 0u) { return(false); } inputEvent.KeyboardInput.Flags = NativeKeyboardEventFlags.Up; return(User32.SendInput(1u, ref inputEvent, NativeInputEvent.Size) != 0u); } else if ((state & KeyStates.Down) == KeyStates.Down) { inputEvent.KeyboardInput.Flags = NativeKeyboardEventFlags.Down; return(User32.SendInput(1u, ref inputEvent, NativeInputEvent.Size) != 0u); } else { inputEvent.KeyboardInput.Flags = NativeKeyboardEventFlags.Up; return(User32.SendInput(1u, ref inputEvent, NativeInputEvent.Size) != 0u); } }
/// <summary> Sends a key press. </summary> /// /// /// <param name="state" type="KeyStates"> The state. </param> /// <param name="key" type="Key"> The key. </param> public void SendKeyPress(KeyStates state, Key key) { if (state != KeyStates.Toggled) { if (PostMessage( hWnd: _ffxivHWnd, Msg: state == KeyStates.Down ? 0x100u : 0x101u, wParam: (IntPtr)KeyInterop.VirtualKeyFromKey(key), lParam: state == KeyStates.Down ? (UIntPtr)0x00500001 : (UIntPtr)0xC0500001)) return; Console.WriteLine(ErrorCode); return; } if (!PostMessage( hWnd: _ffxivHWnd, Msg: 0x100u, wParam: (IntPtr)KeyInterop.VirtualKeyFromKey(key), lParam: (UIntPtr)0x00500001)) { Console.WriteLine(ErrorCode); return; } Thread.Sleep(1); if (!PostMessage( hWnd: _ffxivHWnd, Msg: 0x101u, wParam: (IntPtr)KeyInterop.VirtualKeyFromKey(key), lParam: (UIntPtr)0xC0500001)) Console.WriteLine(ErrorCode); }
public RawKeyboardEventArgs(Key key, KeyStates keyStates, bool isRepeat, int timestamp) : base(timestamp) { this.Key = key; this.KeyStates = keyStates; this.IsRepeat = isRepeat; }
private static IntPtr HookCallback(int nCode, IntPtr wParam, IntPtr lParam) { if (nCode < 0 || Enable == false) { return(API.CallNextHookEx(_hookID, nCode, wParam, lParam)); } API.KBDLLHOOKSTRUCT hookStruct = (API.KBDLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(API.KBDLLHOOKSTRUCT)); Keys key = (Keys)hookStruct.vkCode; KeyStates keyState = KeyStates.None; switch ((API.KeyboardMessages)wParam) { case API.KeyboardMessages.WM_KEYDOWN: { keyState = KeyStates.Down; } break; case API.KeyboardMessages.WM_KEYUP: { keyState = KeyStates.Up; } break; } if (KeyboardAction(new KeyboardActionArgs(key, keyState))) { return((IntPtr)1); } return(API.CallNextHookEx(_hookID, nCode, wParam, lParam)); }
public void SendKeyPress(KeyStates state, Key key) { if (state != KeyStates.Toggled) { if (PostMessage( hWnd: _ffxivHWnd, Msg: state == KeyStates.Down ? 0x100u : 0x101u, wParam: (IntPtr)KeyInterop.VirtualKeyFromKey(key), lParam: state == KeyStates.Down ? (UIntPtr)0x00500001 : (UIntPtr)0xC0500001)) { return; } Console.WriteLine(ErrorCode); return; } if (!PostMessage( hWnd: _ffxivHWnd, Msg: 0x100u, wParam: (IntPtr)KeyInterop.VirtualKeyFromKey(key), lParam: (UIntPtr)0x00500001)) { Console.WriteLine(ErrorCode); return; } Thread.Sleep(1); if (!PostMessage( hWnd: _ffxivHWnd, Msg: 0x101u, wParam: (IntPtr)KeyInterop.VirtualKeyFromKey(key), lParam: (UIntPtr)0xC0500001)) { Console.WriteLine(ErrorCode); } }
//設計図でマウスホイール動いたら private void ScrollViewer_Wheel(MouseWheelEventArgs e) { ScrollViewer scrollviewer = Tree_Scroll; KeyStates key_shiftL = KeyStateFilter(Keyboard.GetKeyStates(Key.LeftShift)); KeyStates key_shiftR = KeyStateFilter(Keyboard.GetKeyStates(Key.RightShift)); if (key_shiftL == KeyStates.Down || key_shiftR == KeyStates.Down) { if (e.Delta > 0) { scrollviewer.LineLeft(); } else { scrollviewer.LineRight(); } } else { if (e.Delta > 0) { scrollviewer.LineUp(); } else { scrollviewer.LineDown(); } } e.Handled = true; }
//點擊Release private void ClickRelease(object sender, EventArgs e) { _press.Checked = false; _hold.Checked = false; _release.Checked = true; _keyState = KeyStates.Release; }
internal GlobalKeyboardEventArgs(Key notifyKey, KeyStates state, IReadOnlyCollection <Key> downStateKeys, long messageTime) { NotifyKey = notifyKey; State = state; DownStateKeys = downStateKeys; MessageTime = messageTime; }
public static bool SendMouseEvent(Keys key, KeyStates state) { uint mouseData = 0u; if (key == Keys.XButton1) { mouseData = 1u; } if (key == Keys.XButton2) { mouseData = 2u; } if ((state & KeyStates.Toggled) == KeyStates.Toggled) { User32.MouseEvent(GetMouseEventFlags(key, true), 0u, 0u, mouseData, IntPtr.Zero); User32.MouseEvent(GetMouseEventFlags(key, false), 0u, 0u, mouseData, IntPtr.Zero); } else if ((state & KeyStates.Down) == KeyStates.Down) { User32.MouseEvent(GetMouseEventFlags(key, true), 0u, 0u, mouseData, IntPtr.Zero); } else { User32.MouseEvent(GetMouseEventFlags(key, false), 0u, 0u, mouseData, IntPtr.Zero); } return(true); }
void mirror() { desc.text = "You: Well, atleast I still have my 69 packed abs. \n\n" + "Press R to stop looking at the mirror"; if (Input.GetKeyDown(KeyCode.R)) { currState = KeyStates.cell; } }
/// <summary> /// Converts a KeyStates enum value to a signed int. /// </summary> /// <param name="state">A KeyStates enum value.</param> /// <returns>The signed int this method returns.</returns> public static int ToInt(KeyStates state) { if (ValidationHelper.IsKeyStatesOutOfRange(state)) { throw ThrowHelper.InvalidEnumArgumentException(nameof(state), state); } return((int)state); }
public KeyDetectedArgument( Key key, KeyStates keyState, bool isControlDown) { Key = key; KeyState = keyState; IsControlDown = isControlDown; }
public static void Keyboardd() { while (true) { Thread.Sleep(50); _key = Keyboard.GetKeyStates(Key.RightCtrl); Console.WriteLine(_key); } }
/// <summary> /// Converts a KeyStates enum value to a human readable string. /// </summary> /// <param name="state">A KeyStates enum value.</param> /// <returns>The string this method generates.</returns> public static string ToString(KeyStates state) { if (ValidationHelper.IsKeyStatesOutOfRange(state)) { throw ThrowHelper.InvalidEnumArgumentException(nameof(state), state); } return(state.ToString()); }
private void ResetState() { currentLevel.Reset(); player = currentLevel.Player; cursor.MoveTo(player.Position); currentLevel.Sprites.Add(cursor.SpriteContainer); camera.Reset(player.Position); keyState = new KeyStates(); mouseState = new MouseState(); }
private void SafeSetState(Key key, bool state) { if (KeyStates.ContainsKey(key)) { KeyStates[key] = state; } else { KeyStates.Add(key, state); } }
public void AddInput(string key, KeyStates state) { if (KeyStateses.ContainsKey(key)) { KeyStateses[key] = state; } else { KeyStateses.Add(key, state); } }
private void InitState() { AStarSearch.SetMesh(currentLevel.NavMesh); player = currentLevel.Player; camera = new Camera(player.Position, player.Radius, screenSize); cursor = new CustomCursor(player.Position.Copy()); currentLevel.Sprites.Add(cursor.SpriteContainer); keyState = new KeyStates(); mouseState = new MouseState(); livingBotsAmount = currentLevel.Bots.Count; }
// 改變可操縱視窗狀態並保存目前狀態,由按鍵狀態的改變來致能 (None -> Down or Down -> None) private void ToggleManipulateWindow(KeyStates inKeyStates) { if (inKeyStates != gKeyStates) { canManipulateWindow = !canManipulateWindow; WindowsServices.SetWindowExTransparent(hwnd); gKeyStates = inKeyStates; } }
public void ShowBuffer() { string asciiText = ""; KeyStates keyStates = new KeyStates(ShiftStates.Unknown, ConfigManager.Instance.Config.CodeSet); for (int i = 0; i < _buffer.Count; i++) { string asciiStr = CodeManager.BaudotStringToAscii(new byte[] { _buffer[i].Code }, keyStates, CodeManager.SendRecv.Send, false); asciiText += asciiStr; } ShowBufferEvt?.Invoke(asciiText); }
void stateKey(KeyEventArgs args, KeyboardRecord kRA) { kRA.Key = args.Key.ToString(); // Store for any character if (args.Key == System.Windows.Input.Key.ImeProcessed) { kRA.ImeProcessedKey = args.ImeProcessedKey.ToString(); } // Store State for Shift, Alt and Control Key KeyStates states = System.Windows.Input.Keyboard.GetKeyStates(System.Windows.Input.Key.RightShift); if (states == KeyStates.Down) { kRA.Shift = true; } states = System.Windows.Input.Keyboard.GetKeyStates(System.Windows.Input.Key.LeftShift); if (states == KeyStates.Down) { kRA.Shift = true; } states = System.Windows.Input.Keyboard.GetKeyStates(System.Windows.Input.Key.LeftAlt); if (states == KeyStates.Down) { kRA.Alt = true; } states = System.Windows.Input.Keyboard.GetKeyStates(System.Windows.Input.Key.RightAlt); if (states == KeyStates.Down) { kRA.Alt = true; } states = System.Windows.Input.Keyboard.GetKeyStates(System.Windows.Input.Key.RightCtrl); if (states == KeyStates.Down) { kRA.Control = true; } states = System.Windows.Input.Keyboard.GetKeyStates(System.Windows.Input.Key.LeftCtrl); if (states == KeyStates.Down) { kRA.Control = true; } }
private void ToggleManipulateWindow(KeyStates inKeyStates) { /* None -> Down, Down -> None : 改變可操縱視窗狀態並保存目前狀態 * None -> None, Down -> Down : 不做任何事 */ if (inKeyStates != gKeyStates) // 狀態改變則致能 { canManipulateWindow = (canManipulateWindow) ? false : true; WindowsServices.SetWindowExTransparent(hwnd); gKeyStates = inKeyStates; } }
/// <summary> /// 入力されたキーを送信する。 /// </summary> private void Window_PreviewKeyDown(object sender, KeyEventArgs e) { Key key = e.Key; Key systemKey = e.SystemKey; KeyStates keyStates = e.KeyStates; bool isRepeat = e.IsRepeat; // IMEの処理中でなければ送信する。 if (key != Key.ImeProcessed) { if (key == Key.A && false) { for (int i = 0; i < 0x86; i++) { if (i >= 0x3a && i <= 0x48) { continue; } Task t = kbd.SendAsync(KeyCode.MOD_LSHIFT, (byte)i, 20); } } else { if (key == Key.System) { key = systemKey; } byte code = (byte)KeyCode.KeyToCode(key); ModifierKeys modKey = Keyboard.Modifiers; byte mod = 0; if ((modKey & ModifierKeys.Alt) != ModifierKeys.None) { mod |= KeyCode.MOD_LALT; } if ((modKey & ModifierKeys.Control) != ModifierKeys.None) { mod |= KeyCode.MOD_LCTRL; } if ((modKey & ModifierKeys.Shift) != ModifierKeys.None) { mod |= KeyCode.MOD_LSHIFT; } if ((modKey & ModifierKeys.Windows) != ModifierKeys.None) { mod |= KeyCode.MOD_LWINDOWS; } Task t = kbd.SendAsync(mod, code, 20); } e.Handled = true; } }
public static KeysModifiers GetModifiers() { KeysModifiers m = KeysModifiers.None; KeyStates shiftState = GetKeyState(Keys.LeftShift, RegisteredKeyStates); if (shiftState == KeyStates.Released | shiftState == KeyStates.Releasing) { shiftState = GetKeyState(Keys.RightShift, RegisteredKeyStates); } if (shiftState == KeyStates.Pressed | shiftState == KeyStates.Pressing) { m |= KeysModifiers.Shift; } if (KeysMethods.CapsLocked()) { if (m.HasFlag(KeysModifiers.Shift)) { m &= ~KeysModifiers.Shift; } else { m |= KeysModifiers.Shift; } } KeyStates altState = GetKeyState(Keys.LeftAlt, RegisteredKeyStates); if (altState == KeyStates.Released | altState == KeyStates.Releasing) { altState = GetKeyState(Keys.RightAlt, RegisteredKeyStates); } if (altState == KeyStates.Pressed | altState == KeyStates.Pressing) { m |= KeysModifiers.Alt; } KeyStates ctrlState = GetKeyState(Keys.LeftControl, RegisteredKeyStates); if (ctrlState == KeyStates.Released | ctrlState == KeyStates.Releasing) { ctrlState = GetKeyState(Keys.RightControl, RegisteredKeyStates); } if (ctrlState == KeyStates.Pressed | ctrlState == KeyStates.Pressing) { m |= KeysModifiers.Control; } return(m); }
void note_0() { desc.text = "Hey there Uncle DoucheBag! I can't belive you got framed! \n\n " + "My GTA5 Crew is going to pull a heist so u can escape! \n\n" + " - Sincerly, Douchy Jr. \n\n" + "You: God damn it Douchy JR! I guess I do have to get revenge on cool giy grylls tho.. \n\n" + "Press R to stop reading."; if (Input.GetKeyDown(KeyCode.R)) { currState = KeyStates.cell; } }
private KeyStates KeyStateFilter(KeyStates k) { var key_OK = KeyStates.Down | KeyStates.Toggled; if (k == key_OK) { return(KeyStates.Down); } else { return(k); } }
private static KeyStates GetKeyState(Keys key) { KeyStates state = KeyStates.None; short retVal = GetKeyState((int)key); if ((retVal & 0x8000) == 0x8000) { state = KeyStates.Down; } return(state); }
public static Keys[] GetAllKeys(KeyStates states) { List <Keys> keys = new List <Keys>(RegisteredKeyStates.Count); foreach (KeyValuePair <Keys, KeyStates> keystate in RegisteredKeyStates) { if ((keystate.Value & states) != 0) { keys.Add(keystate.Key); } } return(keys.ToArray()); }
/// <summary> /// Get element that is hit on mouse down in 3d viewport. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void onMouseDown3DHandler(object sender, MouseDown3DEventArgs e) { MouseEventArgs mouseArgs = e.OriginalInputEventArgs as MouseEventArgs; // check if the shift key is held down bool shiftDown = false; KeyStates state1 = Keyboard.GetKeyStates(Key.LeftShift); KeyStates state2 = Keyboard.GetKeyStates(Key.RightShift); if ((state1 & KeyStates.Down) > 0 || (state2 & KeyStates.Down) > 0) { shiftDown = true; } // only pay attention if its a LEFT click if (mouseArgs.LeftButton == MouseButtonState.Pressed) { if (e.HitTestResult != null && e.HitTestResult.ModelHit is GeometryModel3D geo) { // if shift is held, add to the selection if (shiftDown) { //selectionCenterOffset = geo.Geometry.Bound.Center; // must update before updating selection selection.Add(geo); updateSelectionProperties(); previewSelectionMaterial(); highlightSelection(); } // else change selection to only what was clicked else { clearSelection(); //selectionCenterOffset = geo.Geometry.Bound.Center; // must update before updating selection selection.Add(geo); updateSelectionProperties(); previewSelectionMaterial(); highlightSelection(); } } // if they clicked nothing else { if (!shiftDown) { clearSelection(); updateSelectionProperties(); } } } }
void cell() { desc.text = "You were framed by Cool Giy Bear Grylls, You are now in Dank Meme Prison, " + " You have 3 friend's, Shrek,Doge & a call of duty haxor. " + " You are currently in a cell with no mlg doritos, you are distributed an MLG Blunt every 420 hours " + " If you 360 someone in the noscope court, you're given an extra blunt" + "and some mt dew with a 69 pack of doritos \n\n" + "You are now in you're cell, the door is guarded by 2 MLG Hackers, there's a note on you're bed," + "there's also a mirror so you can remind yourself of how bad you are \n\n" + "L to sneak up on the prison lock, M To look at the mirror, N to read the note." ; if (Input.GetKeyDown (KeyCode.N)) { currState = KeyStates.note_0; } else if (Input.GetKeyDown (KeyCode.M)) { currState = KeyStates.mirror; } else if (Input.GetKeyDown (KeyCode.L)) { currState = KeyStates.lock_0; } }
public override void Update(int dt, KeyStates ks) { if (started) { ground.Update(dt); player.Update(dt); if (ks.isKeyDown(Keys.Space)) player.Jump(); if (ground.TestHitWith(player.GetPosition())) Stop(); } else { if (ks.isKeyDown(Keys.Space)) Restart(); } }
public static VsKeyInfo Create(Key key, char keyChar, byte virtualKey, KeyStates keyStates = default(KeyStates), bool shiftPressed = false, bool controlPressed = false, bool altPressed = false, bool capsLockToggled = false, bool numLockToggled = false) { return new VsKeyInfo { Key = key, KeyChar = keyChar, VirtualKey = virtualKey, KeyStates = keyStates, ShiftPressed = shiftPressed, ControlPressed = controlPressed, AltPressed = altPressed, CapsLockToggled = capsLockToggled, NumLockToggled = numLockToggled }; }
void sneak() { desc.text = "You: I wonder if the lock is open \n\n" + "BINGO! CRAP DON'T NISCIP ME I SWEAR ON MI NAN I'LL REK YOU! \n\n" + "Press E to rekt them to mlg Press I to karate niscip them"; if (Input.GetKeyDown(KeyCode.E)) { desc.text = "*You start chanting the REKT song* \n\n" + "The guards died of you're boring voice... \n\n" + "You: F**K YEAH! \n\n" + "Item Accquired: Freedom MLG key"; currState = KeyStates.lock_1; } else if(Input.GetKeyDown(KeyCode.I)){ desc.text = "Due to no one giving a shit, you and you're new friends seized the f**k out of the new guards \n\n" + "Because logic is 0 in this world, donate now to support the doge movement \n\n" + "Item Accquired: Freedom MLG key"; currState = KeyStates.lock_1; } }
public KeyEventArgs(RoutedEvent routedEvent, object originalSource, KeyboardDevice keyboardDevice, int timestamp, Key key, KeyStates keyStates, bool isRepeat) : base(routedEvent, originalSource, keyboardDevice, timestamp) { this.Key = key; this.KeyStates = keyStates; this.IsRepeat = isRepeat; }
void mirror() { desc.text = "You: Well, atleast I still have my 69 packed abs. \n\n" + "Press R to stop looking at the mirror"; if(Input.GetKeyDown(KeyCode.R)){ currState = KeyStates.cell; } }
public KeyboardData(int virtualCode, KeyStates keyState) { Key = new KeyboardCode(virtualCode); State = new KeyState(keyState); }
public wpf::System.Windows.Input.KeyStates Convert(KeyStates keyStates) { return (wpf::System.Windows.Input.KeyStates)((int)keyStates); }
void note_0() { desc.text = "Hey there Uncle DoucheBag! I can't belive you got framed! \n\n " + "My GTA5 Crew is going to pull a heist so u can escape! \n\n" + " - Sincerly, Douchy Jr. \n\n" + "You: God damn it Douchy JR! I guess I do have to get revenge on cool giy grylls tho.. \n\n" + "Press R to stop reading."; if(Input.GetKeyDown(KeyCode.R)){ currState = KeyStates.cell; } }
public static IEnumerable<IVIMAction> GetVIMCommand(CommandMode mode, Key keyStroke, KeyStates keyStates) { yield return _commands.Get(mode).Get(keyStates).Get(keyStroke); }
/// <summary> /// 设置键盘上某个按键当前状态 /// </summary> public void SetKeyboardState(Key key, KeyStates state) { UpdateRender.KS_KEY_Dict[key] = state; }
public KeyState() { InitializeComponent(); _keyState = KeyStates.None; }
public static IEnumerable<IDictionary> Get(this IDictionary src, KeyStates keyStates) { if (src != null ? src.Contains(keyStates) : false) return src[keyStates] as IEnumerable<IDictionary>; return null; }
public abstract void Update(int dt, KeyStates ks);
void rkthing() { desc.text = "You use the key you accquired, you unlock every cell, and rally everyone up \n\n" + "you: ok giys, we need to kill the owner of this prisonnnzzzz, which is cool giy gryllz \n\n" + "press t to go in style, press O to go wITH StYLe"; if (Input.GetKeyDown (KeyCode.T)) { desc.text = "You have succesfully hit the run, now go find that son of a giy"; currState = KeyStates.freedom; } else if (Input.GetKeyDown (KeyCode.O)) { desc.text = "You have succesfully hit the run with f*****g style, now go destroy dat giy"; currState = KeyStates.freedom; } }
public override bool UIKeyPressed(int code, KeyStates state) { if (state == (KeyStates.Control | KeyStates.Alt)) { /* */ } else if (state == (KeyStates.Control)) { switch (code) { case VKeyCode.R: return tryRefresh(); } } else if (state == (KeyStates.Shift)) { switch (code) { case VKeyCode.F3: return tryMenuOperation(); } } else if (state == (KeyStates.None)) { /* */ } return base.UIKeyPressed(code, state); }
public Key(VirtualKeyCode code, KeyStates state) { _state = state; _code = code; }
void Start() { currState = KeyStates.cell; }
public void AddKey(VirtualKeyCode key, KeyStates state) { _keys.Add(new Key(key, state)); }