Exemple #1
0
        private void SendCharacter(char character)
        {
            var input = new User32.INPUT[] {
                new User32.INPUT() {
                    Type = User32.INPUT_KEYBOARD,
                    ki = new User32.KEYBDINPUT() {
                        wVk = 0,
                        wScan = character,
                        dwFlags = User32.KEYEVENTF_UNICODE,
                        time = 0,
                        dwExtraInfo = IntPtr.Zero
                    }
                },
                new User32.INPUT() {
                    Type = User32.INPUT_KEYBOARD,
                    ki = new User32.KEYBDINPUT() {
                        wVk = 0,
                        wScan = character,
                        dwFlags = User32.KEYEVENTF_UNICODE | User32.KEYEVENTF_KEYUP,
                        time = 0,
                        dwExtraInfo = IntPtr.Zero
                    }
                }
            };

            IntegrationHelper.SendInput(input);
        }
Exemple #2
0
        private void SendKey(ushort vk, uint dwFlags)
        {
            var input = new User32.INPUT[] {
                new User32.INPUT() {
                    Type = User32.INPUT_KEYBOARD,
                    ki = new User32.KEYBDINPUT() {
                        wVk = vk,
                        wScan = 0,
                        dwFlags = dwFlags,
                        time = 0,
                        dwExtraInfo = IntPtr.Zero
                    }
                }
            };

            if (IsExtendedKey(vk))
            {
                input[0].ki.dwFlags |= User32.KEYEVENTF_EXTENDEDKEY;
            }

            IntegrationHelper.SendInput(input);
        }