예제 #1
0
        /// <summary>
        /// Immediately release a key, by sending a keyup event to the game.
        /// </summary>
        /// <param name="key">The scan code (NOT the VK_ keycode!) of the key to release.</param>
        public void Keyup(ScanCode key)
        {
            lock (pressed_keys)
            {
                if (!pressed_keys.Contains(key))
                {
                    return;
                }

                pressed_keys.Remove(key);
            }
            SendInputWrapper.SendInput(new INPUT
            {
                Type = (uint)InputType.Keyboard,
                Data =
                {
                    Keyboard      = new KEYBDINPUT
                    {
                        Vk        =                                                      0,
                        Scan      = (ushort)key,
                        Flags     = (uint)KeyboardFlag.ScanCode | (uint)KeyboardFlag.KeyUp,
                        Time      =                                                      0,
                        ExtraInfo = IntPtr.Zero
                    }
                }
            });
        }
예제 #2
0
        private void MainForm_KeyDown(object sender, System.Windows.Forms.KeyEventArgs args)
        {
            if (hotkeyEntering)
            {
                uint key = (uint)args.KeyCode;

                ScanCode code = (ScanCode)MapVirtualKeyA(key);

                if (code == ScanCode.Control || code == ScanCode.RShift || code == ScanCode.LShift ||
                    code == ScanCode.Alt)
                {
                    code = ScanCode.None;
                }

                Hotkey.Modifiers hkMods = new Hotkey.Modifiers();

                if (args.Alt)
                {
                    hkMods = hkMods |= Hotkey.Modifiers.Alt;
                }
                if (args.Shift)
                {
                    hkMods = hkMods |= Hotkey.Modifiers.Shift;
                }
                if (args.Control)
                {
                    hkMods = hkMods |= Hotkey.Modifiers.Ctrl;
                }

                Hotkey hk = new Hotkey(code, hkMods);
                lastEnteredHotkey       = hk;
                ClientHotkeyButton.Text = hk.ToString();
            }
        }
예제 #3
0
        private void btnAddScan_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(txtScanCd.Text))
            {
                MessageBox.Show("Please Enter Scancode.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            ProductRepository repository = new ProductRepository();

            if (!repository.CheckScan(txtScanCd.Text))
            {
                ScanCode scan = new ScanCode();
                scan.ScanCd    = txtScanCd.Text;
                scan.ProdCd    = _Product.ProdCd;
                scan.Unitcd    = _Product.UnitCd;
                scan.CreatedBy = "ADMIN";
                if (repository.SaveScan(scan))
                {
                    PopulateDgv();
                    txtScanCd.Text = "";
                }
                else
                {
                    MessageBox.Show("Error occurred. Please Try Again.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            else
            {
                MessageBox.Show("The ScanCode Exists in the Database", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
예제 #4
0
        /// <summary>
        /// Calls the Win32 SendInput method with a KeyDown and KeyUp message in the same input sequence in order to simulate a Key PRESS.
        /// </summary>
        /// <param name="keyCode">The HardwareKeyCode to press</param>
        public static void HardwareKeyPress(ScanCode keyCode)
        {
            var down = new INPUT();
            down.Type = (UInt32)InputType.KEYBOARD;
            down.Data.Keyboard = new KEYBDINPUT();
            down.Data.Keyboard.Vk = 0;
            down.Data.Keyboard.Scan = (UInt16)keyCode;
            down.Data.Keyboard.Flags = KeyboardFlag.SCANCODE;
            down.Data.Keyboard.Time = 0;
            down.Data.Keyboard.ExtraInfo = IntPtr.Zero;

            var up = new INPUT();
            up.Type = (UInt32)InputType.KEYBOARD;
            up.Data.Keyboard = new KEYBDINPUT();
            up.Data.Keyboard.Vk = 0;
            up.Data.Keyboard.Scan = (UInt16)keyCode;
            up.Data.Keyboard.Flags = KeyboardFlag.SCANCODE | KeyboardFlag.KEYUP;
            up.Data.Keyboard.Time = 0;
            up.Data.Keyboard.ExtraInfo = IntPtr.Zero;

            if (((int)keyCode & 0xFF00) == 0xE000)
            { // extended key?
                down.Data.Keyboard.Flags |= KeyboardFlag.EXTENDEDKEY;
                up.Data.Keyboard.Flags |= KeyboardFlag.EXTENDEDKEY;
            }

            INPUT[] inputList = new INPUT[2];
            inputList[0] = down;
            inputList[1] = up;

            var numberOfSuccessfulSimulatedInputs = SendInput(2, inputList, Marshal.SizeOf(typeof(INPUT)));
            if (numberOfSuccessfulSimulatedInputs == 0) throw new Exception(string.Format("The key press simulation for {0} was not successful.", keyCode));
        }
예제 #5
0
        public static void Send(ScanCode scanCode, bool keyDown, bool isEXTEND = false)
        {
            Debug.WriteLine(scanCode.ToString() + " " + (keyDown ? "(DOWN)" : "(UP)"));

            if (IntPtr.Size == 8)
            {
                INPUT64 inp = new INPUT64();

                inp.type           = INPUT_KEYBOARD;
                inp.ki.wScan       = (short)scanCode;
                inp.ki.dwFlags     = (uint)(KEYEVENTF_SCANCODE | (keyDown ? KEYEVENTF_KEYDOWN : KEYEVENTF_KEYUP));
                inp.ki.time        = 0;
                inp.ki.dwExtraInfo = IntPtr.Zero;
                SendInput64(1, ref inp, Marshal.SizeOf(inp));
            }
            else
            {
                INPUT inp = new INPUT();

                inp.type           = INPUT_KEYBOARD;
                inp.ki.wScan       = (ushort)scanCode;
                inp.ki.dwFlags     = (uint)(KEYEVENTF_SCANCODE | (keyDown ? KEYEVENTF_KEYDOWN : KEYEVENTF_KEYUP));
                inp.ki.time        = 0;
                inp.ki.dwExtraInfo = IntPtr.Zero;
                SendInput(1, ref inp, Marshal.SizeOf(inp));
            }
        }
예제 #6
0
파일: InputHelper.cs 프로젝트: nchos88/SOA
        private INPUT GetKeyboardDownInput(char character)
        {
            ScanCode scanCode = (ScanCode)character;

            INPUT keyInput = new INPUT
            {
                type   = InputType.INPUT_KEYBOARD,
                Inputs =
                {
                    ki                     = new KEYBDINPUT
                    {
                        wScan              = scanCode,
                        wVk                =                           0,
                        dwFlags            = KEYEVENTF.KEYEVENTF_UNICODE,
                        time               =                           0,
                        dwExtraInfo_IntPtr = IntPtr.Zero
                    }
                }
            };

            if (((int)scanCode & 0xFF00) == 0xE000)
            {
                keyInput.Inputs.ki.dwFlags |= KEYEVENTF.KEYEVENTF_EXTENDED_KEY;
            }

            return(keyInput);
        }
예제 #7
0
        private void BasicWindow_KeyDown(object sender, KeyEventArgs e)
        {
            // we take over Shift+F11 and Shift+F5
            if ((Control.ModifierKeys & Keys.Shift) == Keys.Shift)
            {
                switch (e.KeyCode)
                {
                case Keys.F11:
                    FullScreenToggle();
                    break;

                case Keys.F5:
                    this.debugWindow.RunButton_Click(sender, null);
                    break;
                }
            }

            ScanCode scanCode = ScanCodes.GetScanCode(e.KeyCode);

            if (scanCode != ScanCode.sc_null)
            {
                e.Handled           = true;
                lastKeyPressed.Text = "$" + ((byte)scanCode).ToString("X2");
                if (kernel.MemMgr != null && !kernel.CPU.DebugPause)
                {
                    kernel.MemMgr.KEYBOARD.WriteKey(scanCode);
                }
            }
            else
            {
                lastKeyPressed.Text = "";
            }
        }
예제 #8
0
        protected virtual void ProcessKeyEvent(char asciiChar, Key key, ScanCode scanCode, KeyState keyState, bool shiftPressed, bool ctrlPressed, bool altPressed)
        {
            var keyEvent = new KeyEvent(
                ActiveApplicationMonitor.GetActiveApplicationName(),
                asciiChar,
                scanCode,
                key,
                keyState,
                shiftPressed,
                altPressed,
                ctrlPressed,
                DateTime.Now
                );

            switch (keyState)
            {
            case KeyState.Up:
                FireKeyUpEvent(keyEvent);
                break;

            case KeyState.Down:
                FireKeyDownEvent(keyEvent);
                break;
            }
            FireKeyActivityEvent(keyEvent);
        }
예제 #9
0
        public void Stop()
        {
            if (!keyRepeatRunning)
            {
                return;
            }

            lastKeyPressed   = 0;
            keyRepeatRunning = false;
            keyRepeatEvent.Set();
            keyRepeatEvent.Close();

            if (Thread.CurrentThread != keyRepeatThread)
            {
                if (!keyRepeatExit.WaitOne(1000))
                {
                    System.Diagnostics.Debug.WriteLine("KeyRepeater.Stop: keyRepeatStop timed out");
                    keyRepeatThread.Abort();
                }
            }

            keyRepeatExit.Close();

            keyRepeatThread = null;
        }
예제 #10
0
 /// <summary>
 /// Same as Tap but also waits a bit after letting go so that we don't get ahead of ourselves
 /// </summary>
 /// <param name="key"></param>
 public void TapWait(ScanCode key)
 {
     Keydown(key);
     Thread.Sleep(100);
     Keyup(key);
     Thread.Sleep(100);
 }
예제 #11
0
 public void ClearKey()
 {
     lastKeyPressed = 0;
     if (!keyRepeatEvent.SafeWaitHandle.IsClosed)
     {
         keyRepeatEvent.Set();
     }
 }
예제 #12
0
 public override bool CanParse()
 {
     if (!base.CanParse())
     {
         return(false);
     }
     return(ScanCode.StartsWith(FrameStart) && ScanCode.EndsWith(FrameEnd) ? true : false);
 }
예제 #13
0
        internal KeyEventArgs(ScanCode scanCode, KeyCode keyCode, KeyModifiers modifiers, bool isRepeat)
        {
            ScanCode  = scanCode;
            KeyCode   = keyCode;
            Modifiers = modifiers;

            IsRepeat = isRepeat;
        }
예제 #14
0
 public KeyEventInfo(VirtualKey vkCode, ScanCode scanCode, KeyEventFlags flags, uint time, UIntPtr dwExtraInfo)
     : this()
 {
     VkCode      = vkCode;
     ScanCode    = scanCode;
     Flags       = flags;
     Time        = time;
     DwExtraInfo = dwExtraInfo;
 }
예제 #15
0
        public static void SendInput(ScanCode scanCode, VirtualKeys virtualKey, KeyEventFlag keyEvent)
        {
            var inputs = new[]
            {
                CreateKeyboardInput(scanCode, virtualKey, keyEvent),
            };

            Win32.SendInput(1, inputs, Input.Size);
        }
예제 #16
0
        protected virtual void KeyRepeat(ScanCode repeatingKey)
        {
            var inputData = new InputWrapper[1]
            {
                InputSimulator.KeyWrapper(repeatingKey, false, ((int)repeatingKey & 0x100) == 0x100)
            };

            Interop.SendInput((uint)inputData.Length, inputData);
        }
예제 #17
0
        public static uint DoKeyDown(ScanCode scanCode, bool extended)
        {
            var inputData = new InputWrapper[]
            {
                KeyWrapper(scanCode, false, extended)
            };

            return(Interop.SendInput(1, inputData));
        }
예제 #18
0
        public void KeyUp(ScanCode scanCode)
        {
            if (scanCode == lastKeyPressed)
            {
                lastKeyPressed = 0;
            }

            keyRepeatEvent.Set();
        }
예제 #19
0
        public static uint Send(ScanCode code)
        {
            Input input = new Input();

            input.Type = InputType.Keyboard;
            input.Data.Keyboard.dwFlags = KeyEventFlags.ScanCode;
            input.Data.Keyboard.wScan   = code;
            input.Data.Keyboard.time    = 0;
            return(SendInput(1, new Input[] { input }, Input.Size));
        }
예제 #20
0
        public uint KeyTap(ScanCode scanCode, bool extended = false)
        {
            var inputData = new InputWrapper[]
            {
                KeyWrapper(scanCode, false, extended),
                KeyWrapper(scanCode, true, extended)
            };

            return(Interop.SendInput(2, inputData));
        }
예제 #21
0
 private void Subscribe_OnClick(object sender, RoutedEventArgs e)
 {
     _scannerIds.Add(Trader.SubscribeScanner(new ScannerFilter
     {
         ScanCode     = ScanCode.GetSelectedValue <ScannerFilterTypes>() ?? ScannerFilterTypes.TopPercGain,
         BoardCode    = BoardCode.Text,
         SecurityType = SecurityType.Text,
         RowCount     = 15,
     }));
 }
예제 #22
0
        private static string GetNameInternal(ScanCode sc)
        {
            return(sc switch
            {
                D0 => "0",
                D1 => "1",
                D2 => "2",
                D3 => "3",
                D4 => "4",
                D5 => "5",
                D6 => "6",
                D7 => "7",
                D8 => "8",
                D9 => "0",

                Backquote => "`",
                Minus => "-",
                ScanCode.Equals => "=",
                LeftSquareBracket => "[",
                RightSquareBracket => "]",
                Backslash => "\\",
                Semicolon => ";",
                Apostrophe => "\"",
                Comma => ",",
                Period => ".",
                Slash => "/",

                LeftShift => "L Shift",
                RightShift => "R Shift",
                LeftControl => "L Ctrl",
                RightControl => "R Ctrl",
                LeftAlt => "L Alt",
                RightAlt => "R Alt",
                LeftMeta => "L Meta",
                RightMeta => "R Meta",

                KpDivide => "Keypad /",
                KpMultiply => "Keypad *",
                KpMinus => "Keypad -",
                KpPlus => "Keypad +",
                KpEnter => "Keypad Enter",
                Kp0 => "Keypad 0",
                Kp1 => "Keypad 1",
                Kp2 => "Keypad 2",
                Kp3 => "Keypad 3",
                Kp4 => "Keypad 4",
                Kp5 => "Keypad 5",
                Kp6 => "Keypad 6",
                Kp7 => "Keypad 7",
                Kp8 => "Keypad 8",
                Kp9 => "Keypad 9",
                KpPeriod => "Keypad .",

                _ => sc.ToString(),
            });
예제 #23
0
 public void SetKeyState(ScanCode key, bool down)
 {
     if (down)
     {
         Keydown(key);
     }
     else
     {
         Keyup(key);
     }
 }
예제 #24
0
 public static void KeyUp(ScanCode scanCode, bool extended = false)
 {
     if (scanCode == currentRepeatingKey.Code && extended == currentRepeatingKey.Extended)
     {
         keyRepeater.CancelAsync();
     }
     else
     {
         DoKeyUp(scanCode, extended);
     }
 }
예제 #25
0
        public static void Send(ScanCode key)
        {
            INPUT Input = new INPUT
            {
                type = 1 // 1 = Keyboard Input
            };

            Input.U.ki.wScan   = key;
            Input.U.ki.dwFlags = KEYEVENTF.SCANCODE;

            SendInput(1, new INPUT[] { Input }, INPUT.Size);
        }
예제 #26
0
 public override bool CanParse()
 {
     if (!base.CanParse())
     {
         return(false);
     }
     if (ScanCode.StartsWith(FrameStart))
     {
         return(true);
     }
     return(ScanCode.StartsWith(AI01.Id) && ScanCode.Length >= 16 ? true : false);
 }
예제 #27
0
        public static Key Handle(Key key)
        {
            ScanCode inputScanCode    = SlimDXScanCodeMap[(int)key];
            Keys     virtualKey       = (Keys)BizHawk.Common.Win32Imports.MapVirtualKey((uint)inputScanCode, MAPVK_VSC_TO_VK_EX);
            ScanCode standardScanCode = GetStandardScanCode(virtualKey);

            if (standardScanCode == 0)
            {
                standardScanCode = inputScanCode;
            }
            return(ScanCodeToSlimDXKey[standardScanCode]);
        }
예제 #28
0
        public static void InjectKey(bool keyUp, ScanCode code)
        {
            tagKEYBDINPUT input = new tagKEYBDINPUT()
            {
                wScan = code
            };

            if (keyUp)
            {
                input.dwFlags = KeyEventFlags.KEYEVENTF_KEYUP;
            }
            InjectKeyboardInput(ref input, 1);
        }
예제 #29
0
        private void ListView_ItemSelected(object sender, SelectedItemChangedEventArgs e)
        {
            var o = ((sender as ListView).SelectedItem) as TestSample;

            Data.IdentifiersToScanCode.Value = "";
            Data.ScanCodeValues = ScanCode.Analyze(o.ScanCode);
            if (Data.ScanCodeValues.Parser != null)
            {
                Data.IdentifiersToScanCode.Value = Data.ScanCodeValues.Parser.IdentifiertsToScanCode();
            }
            // No Binding object!
            Data.RefreshAll();
        }
예제 #30
0
 public static void KeyDown(ScanCode scanCode, bool extended = false, bool repeat = false, int initialPauseTime = 500, int repeatPauseTime = 30)
 {
     if (repeat)
     {
         RepeatKey(new RepeatingKey {
             Code = scanCode, Extended = extended, InitialPauseTime = initialPauseTime, RepeatPauseTime = repeatPauseTime
         });
     }
     else
     {
         DoKeyDown(scanCode, extended);
     }
 }
예제 #31
0
 public override string ToString()
 {
     return("LowLevelKeyboardHookStruct:\r\n{\r\nvkCode: [" +
            VkCode.ToString() +
            " (" + (char)VkCode + ")]\r\nscanCode: [" +
            ScanCode.ToString() +
            "]\r\nflags: [" +
            Flags.ToString() +
            "]\r\ntime: [" +
            Time.ToString() + "]\r\ndwExtraInfo: [" +
            DwExtraInfo.ToString() +
            "]\r\n}");
 }
예제 #32
0
 public static InputWrapper KeyWrapper(ScanCode scanCode, bool keyUp = false, bool extended = false)
 {
     return new InputWrapper
     {
         Type = SendInputType.Keyboard,
         MKH = new MouseKeyboardHardwareUnion
         {
             Keyboard = new KeyboardInputData
             {
                 Scan = scanCode,
                 Flags =
                     KeyboardFlags.ScanCode |
                     (keyUp ? KeyboardFlags.KeyUp : 0) |
                     (extended ? KeyboardFlags.ExtendedKey : 0)
             }
         }
     };
 }
예제 #33
0
        public void Stop()
        {
            if (!keyRepeatRunning)
                return;

            lastKeyPressed = 0;
            keyRepeatRunning = false;
            keyRepeatEvent.Set();
            keyRepeatEvent.Close();

            if (Thread.CurrentThread != keyRepeatThread)
            {
                if (!keyRepeatExit.WaitOne(1000))
                {
                    System.Diagnostics.Debug.WriteLine("KeyRepeater.Stop: keyRepeatStop timed out");
                    keyRepeatThread.Abort();
                }
            }

            keyRepeatExit.Close();

            keyRepeatThread = null;
        }
예제 #34
0
파일: KeyUp.cs 프로젝트: HaKDMoDz/GNet
 public KeyUp(ScanCode scanCode)
 {
     Inputs = new InputWrapper[] { InputSimulator.KeyWrapper(scanCode, true) };
     toString = "KeyUp(" + scanCode.ToString() + ")";
 }
예제 #35
0
 protected abstract void SetInputs(ScanCode scanCode);
예제 #36
0
        public static void KeyTap(ScanCode scanCode)
        {
            var inputData = new InputWrapper[]
            {
                new InputWrapper()
                {
                    Type = SendInputType.Keyboard,
                    MKH = new MouseKeyboardHardwareUnion()
                    {
                        Keyboard = new KeyboardInputData()
                        {
                            Scan = scanCode,
                            Flags = KeyboardFlags.ScanCode,
                            Time = 0,
                            ExtraInfo = IntPtr.Zero
                        }
                    }
                },
                new InputWrapper()
                {
                    Type = SendInputType.Keyboard,
                    MKH = new MouseKeyboardHardwareUnion()
                    {
                        Keyboard = new KeyboardInputData()
                        {
                            Scan = scanCode,
                            Flags = KeyboardFlags.KeyUp | KeyboardFlags.ScanCode,
                            Time = 0,
                            ExtraInfo = IntPtr.Zero
                        }
                    }
                }
            };

            var v = SendInput(2, inputData, Marshal.SizeOf(typeof(InputWrapper)));
        }
예제 #37
0
 public KeyScanCodeDown(ScanCode scanCode) : base(scanCode) { }
예제 #38
0
 public void ClearKey()
 {
     lastKeyPressed = 0;
     if (!keyRepeatEvent.SafeWaitHandle.IsClosed)
         keyRepeatEvent.Set();
 }
예제 #39
0
        public uint KeyTap(ScanCode scanCode, bool extended = false)
        {
            var inputData = new InputWrapper[]
            { 
                KeyWrapper(scanCode, false, extended),
                KeyWrapper(scanCode, true, extended)
            };

            return Interop.SendInput(2, inputData);
        }
예제 #40
0
 protected override void SetInputs(ScanCode scanCode)
 {
     Inputs = new InputWrapper[] { InputSimulator.KeyWrapper(scanCode), InputSimulator.KeyWrapper(scanCode, true) };
 }
예제 #41
0
 public void KeyDown(ScanCode scanCode)
 {
     lastKeyPressed = scanCode;
     keyRepeatEvent.Set();
 }
예제 #42
0
        IList<ScanCode> GetCodes(ScanCode[] scanCodes)
        {
            IList<ScanCode> codes = new List<ScanCode>();
            if (scanCodes != null)
                for (int i = 0; i < scanCodes.Length; i++)
                    codes.Add(scanCodes[i]);

            return codes;
        }
예제 #43
0
 /// <summary>
 /// Performs a simple modified keystroke like CTRL-C where CTRL is the modifierKey and C is the key.
 /// The flow is Modifier KEYDOWN, Key PRESS, Modifier KEYUP.
 /// </summary>
 /// <param name="modifierKeyCode">The modifier key</param>
 /// <param name="keyCode">The key to simulate</param>
 public static void HardwareModifiedKeyStroke(ScanCode modifierKeyCode, ScanCode keyCode)
 {
     HardwareKeyDown(modifierKeyCode);
     HardwareKeyPress(keyCode);
     HardwareKeyUp(modifierKeyCode);
 }
예제 #44
0
 public static void KeyDown(ScanCode scanCode, bool extended = false, bool repeat = false, int initialPauseTime = 500, int repeatPauseTime = 30)
 {
     if (repeat)
         RepeatKey(new RepeatingKey { Code = scanCode, Extended = extended, InitialPauseTime = initialPauseTime, RepeatPauseTime = repeatPauseTime });
     else
         DoKeyDown(scanCode, extended);
 }
예제 #45
0
        public static uint DoKeyDown(ScanCode scanCode, bool extended)
        {
            var inputData = new InputWrapper[]
            {
                KeyWrapper(scanCode, false, extended)
            };

            return Interop.SendInput(1, inputData);
        }
예제 #46
0
 /// <summary>
 /// Performs a modified keystroke where there is one modifier and multiple keys like CTRL-K-C where CTRL is the modifierKey and K and C are the keys.
 /// The flow is Modifier KEYDOWN, Keys PRESS in order, Modifier KEYUP.
 /// </summary>
 /// <param name="modifierKey">The modifier key</param>
 /// <param name="keyCodes">The list of keys to simulate</param>
 public static void HardwareModifiedKeyStroke(ScanCode modifierKey, IEnumerable<ScanCode> keyCodes)
 {
     HardwareKeyDown(modifierKey);
     if (keyCodes != null) keyCodes.ToList().ForEach(x => HardwareKeyPress(x));
     HardwareKeyUp(modifierKey);
 }
예제 #47
0
 public KeyScanCode(ScanCode scanCode)
 {
     ScanCode = scanCode;
 }
예제 #48
0
 public KeyScanCodeTap(ScanCode scanCode) : base(scanCode) { }
예제 #49
0
        protected virtual void KeyRepeat(ScanCode repeatingKey)
        {
            var inputData = new InputWrapper[1]
            {
                InputSimulator.KeyWrapper(repeatingKey, false, ((int)repeatingKey & 0x100) == 0x100)
            };

            Interop.SendInput((uint)inputData.Length, inputData);
        }
예제 #50
0
        static void DoKeyUp(ScanCode scanCode, bool extended)
        {
            var inputData = new InputWrapper[]
                {
                    new InputWrapper()
                    {
                        Type = SendInputType.Keyboard,
                        MKH = new MouseKeyboardHardwareUnion()
                        {
                            Keyboard = new KeyboardInputData()
                            {
                                Scan = scanCode,
                                Flags = KeyboardFlags.KeyUp | KeyboardFlags.ScanCode | (extended ? KeyboardFlags.ExtendedKey : 0)
                                //Time = 0,
                                //ExtraInfo = IntPtr.Zero
                            }
                        }
                    }
                };

            var v = SendInput(1, inputData, Marshal.SizeOf(typeof(InputWrapper)));
        }
예제 #51
0
        public void KeyUp(ScanCode scanCode)
        {
            if (scanCode == lastKeyPressed)
                lastKeyPressed = 0;

            keyRepeatEvent.Set();
        }
예제 #52
0
 public static void KeyUp(ScanCode scanCode, bool extended = false)
 {
     if (scanCode == currentRepeatingKey.Code && extended == currentRepeatingKey.Extended)
         keyRepeater.CancelAsync();
     else
         DoKeyUp(scanCode, extended);
 }
예제 #53
0
 /// <summary>
 /// Performs a modified keystroke where there are multiple modifiers and one key like CTRL-ALT-C where CTRL and ALT are the modifierKeys and C is the key.
 /// The flow is Modifiers KEYDOWN in order, Key PRESS, Modifiers KEYUP in reverse order.
 /// </summary>
 /// <param name="modifierKeyCodes">The list of modifier keys</param>
 /// <param name="keyCode">The key to simulate</param>
 public static void HardwareModifiedKeyStroke(IEnumerable<ScanCode> modifierKeyCodes, ScanCode keyCode)
 {
     if (modifierKeyCodes != null) modifierKeyCodes.ToList().ForEach(x => HardwareKeyDown(x));
     HardwareKeyPress(keyCode);
     if (modifierKeyCodes != null) modifierKeyCodes.Reverse().ToList().ForEach(x => HardwareKeyUp(x));
 }
예제 #54
0
        public uint KeyUp(ScanCode scanCode, bool extended = false)
        {
            uint retval = DoKeyUp(scanCode, extended);

            return retval;
        }