Пример #1
0
        public static void PressKeys(int[] vkCodes)
        {
            if (vkCodes.Length > 0)
            {
                Win32API.VKCodes[] codes = new Win32API.VKCodes[vkCodes.Length];

                for (int i = 0; i < vkCodes.Length; i++)
                {
                    codes[i] = (Win32API.VKCodes)vkCodes[i];
                }

                PressKeys(codes);
            }
        }
Пример #2
0
        /* void PressKey(Win32API.VKCodes vkCode)
         * Press a single key.
         */
        public unsafe static void PressKey(Win32API.VKCodes vkCode)
        {
            Win32API.INPUT *structInput = stackalloc Win32API.INPUT[2];
            structInput[0].type       = structInput[1].type = 1; //keyboard
            structInput[0].ki.wVk     = structInput[1].ki.wVk = (ushort)vkCode;
            structInput[0].ki.time    = structInput[1].ki.time = 0;
            structInput[0].ki.dwFlags = structInput[1].ki.dwFlags = 4; //unicode

            //key up
            structInput[1].ki.dwFlags = 2;

            //send the key
            Win32API.SendInput(2, structInput, Marshal.SizeOf(*structInput));
        }
Пример #3
0
        public static void PressKeys(int[] vkCodes)
        {
            if (vkCodes.Length > 0)
            {
                Win32API.VKCodes[] codes = new Win32API.VKCodes[vkCodes.Length];

                for (int i = 0; i < vkCodes.Length; i++)
                {
                    codes[i] = (Win32API.VKCodes)vkCodes[i];
                }

                PressKeys(codes);
            }
        }