public static void SendBackspace(int count)
        {
            if (count < 1)
            {
                return;
            }

            NativeMethods.KEYBOARDINPUT ip = new NativeMethods.KEYBOARDINPUT();
            ip.type        = NativeMethods.INPUT_KEYBOARD;
            ip.dwExtraInfo = 0;
            ip.time        = 0;

            for (int i = 0; i < count; i++)
            {
                ip.wScan   = 255;
                ip.dwFlags = 0;
                ip.wVk     = (ushort)NativeMethods.VK.BACK;
                NativeMethods.SendInput(1, new NativeMethods.KEYBOARDINPUT[] { ip }, Marshal.SizeOf(typeof(NativeMethods.KEYBOARDINPUT)));

                ip.wScan   = 0;
                ip.dwFlags = NativeMethods.KEYEVENTF.KEYUP;
                ip.wVk     = (ushort)NativeMethods.VK.BACK;
                NativeMethods.SendInput(1, new NativeMethods.KEYBOARDINPUT[] { ip }, Marshal.SizeOf(typeof(NativeMethods.KEYBOARDINPUT)));
            }
        }
        private static uint SendKeyStrokes(String s)
        {
            uint cInputs = (uint)s.Length * 2; // need twice for up and down

            NativeMethods.KEYBOARDINPUT[] ip = new NativeMethods.KEYBOARDINPUT[cInputs];

            for (int i = 0, ii = 0; ii < cInputs; i++, ii++)
            {
                ip[ii].type        = NativeMethods.INPUT_KEYBOARD;
                ip[ii].dwExtraInfo = 0xDEADC0DE;
                ip[ii].dwFlags     = NativeMethods.KEYEVENTF.UNICODE;
                ip[ii].time        = 0;
                ip[ii].wScan       = s[i];
                ip[ii].wVk         = 0;

                ii++;

                ip[ii].type        = NativeMethods.INPUT_KEYBOARD;
                ip[ii].dwExtraInfo = 0;
                ip[ii].dwFlags     = NativeMethods.KEYEVENTF.KEYUP | NativeMethods.KEYEVENTF.UNICODE;
                ip[ii].time        = 0;
                ip[ii].wScan       = s[i];
                ip[ii].wVk         = 0;
            }

            uint cSent = NativeMethods.SendInput(cInputs, ip, Marshal.SizeOf(typeof(NativeMethods.KEYBOARDINPUT)));

            return(cSent / 2);
        }
        public static uint SendSingleVK(ushort wVk, NativeMethods.KEYEVENTF dwFlags)
        {
            NativeMethods.KEYBOARDINPUT ip = new NativeMethods.KEYBOARDINPUT();

            ip.type        = NativeMethods.INPUT_KEYBOARD;
            ip.wScan       = 0;
            ip.dwExtraInfo = 0;
            ip.dwFlags     = dwFlags;
            ip.time        = 0;
            ip.wVk         = wVk;

            return(NativeMethods.SendInput(1, new NativeMethods.KEYBOARDINPUT[] { ip }, Marshal.SizeOf(typeof(NativeMethods.KEYBOARDINPUT))));
        }
        public static uint SendSingleScanCode(ushort scanCode, NativeMethods.KEYEVENTF dwFlags)
        {
            NativeMethods.KEYBOARDINPUT ip = new NativeMethods.KEYBOARDINPUT();

            ip.type        = NativeMethods.INPUT_KEYBOARD;
            ip.wScan       = scanCode;
            ip.dwExtraInfo = 0;
            ip.dwFlags     = dwFlags | NativeMethods.KEYEVENTF.SCANCODE;
            if ((scanCode & 0xE000) == 0xE000)
            {
                ip.dwFlags |= NativeMethods.KEYEVENTF.EXTENDEDKEY;
            }
            ip.time = 0;
            ip.wVk  = 0;

            return(NativeMethods.SendInput(1, new NativeMethods.KEYBOARDINPUT[] { ip }, Marshal.SizeOf(typeof(NativeMethods.KEYBOARDINPUT))));
        }