Exemplo n.º 1
0
        /// <summary>
        /// 現在フォーカスを持つウィンドウに対して指定したキーのUp/Downを送信します。
        /// </summary>
        /// <param name="keyInputs"></param>
        public static UInt32 SendInput(params Keys[] keyInputs)
        {
            List <Win32.INPUT> inputs = new List <Win32.INPUT>();

            foreach (Keys key in keyInputs)
            {
                Debug.WriteLine("SendInput: " + key.ToString());
                Win32.INPUT input = new Win32.INPUT();
                input.ki             = new Win32.KEYBDINPUT();
                input.type           = Win32.INPUT_KEYBOARD;
                input.ki.wScan       = 0;
                input.ki.wVk         = (Byte)key;
                input.ki.dwFlags     = 0; // KEYDOWN
                input.ki.dwExtraInfo = InputExtraInfoValue;
                inputs.Add(input);

                input                = new Win32.INPUT();
                input.ki             = new Win32.KEYBDINPUT();
                input.type           = Win32.INPUT_KEYBOARD;
                input.ki.wScan       = 0;
                input.ki.wVk         = (Byte)key;
                input.ki.dwFlags     = Win32.KEYEVENTF_KEYUP; // KEYUP
                input.ki.dwExtraInfo = InputExtraInfoValue;
                inputs.Add(input);
            }
            Win32.INPUT[] inputsArr = inputs.ToArray();

            return(Win32.SendInput((UInt32)inputsArr.Length, inputsArr, Marshal.SizeOf(typeof(Win32.INPUT))));
        }
Exemplo n.º 2
0
        /// <summary>
        /// ���݃t�H�[�J�X����ƒE�B���h�E�ɑ΂��Ďw�肵���L�[��Up/Down�𑗐M���܂��B
        /// </summary>
        /// <param name="keyInputs"></param>
        public static UInt32 SendInput(params Keys[] keyInputs)
        {
            List<Win32.INPUT> inputs = new List<Win32.INPUT>();
            foreach (Keys key in keyInputs)
            {
                Debug.WriteLine("SendInput: " + key.ToString());
                Win32.INPUT input = new Win32.INPUT();
                input.ki = new Win32.KEYBDINPUT();
                input.type = Win32.INPUT_KEYBOARD;
                input.ki.wScan = 0;
                input.ki.wVk = (Byte)key;
                input.ki.dwFlags = 0; // KEYDOWN
                input.ki.dwExtraInfo = InputExtraInfoValue;
                inputs.Add(input);

                input = new Win32.INPUT();
                input.ki = new Win32.KEYBDINPUT();
                input.type = Win32.INPUT_KEYBOARD;
                input.ki.wScan = 0;
                input.ki.wVk = (Byte)key;
                input.ki.dwFlags = Win32.KEYEVENTF_KEYUP; // KEYUP
                input.ki.dwExtraInfo = InputExtraInfoValue;
                inputs.Add(input);
            }
            Win32.INPUT[] inputsArr = inputs.ToArray();

            return Win32.SendInput((UInt32)inputsArr.Length, inputsArr, Marshal.SizeOf(typeof(Win32.INPUT)));
        }
Exemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="isUp"></param>
        /// <param name="keyInput"></param>
        public static UInt32 SendInput(Boolean isUp, Keys key)
        {
            Debug.WriteLine("SendInput: " + key.ToString() + " ( " + (isUp ? "Up" : "Down") + ")");
            Win32.INPUT input = new Win32.INPUT();
            input.ki             = new Win32.KEYBDINPUT();
            input.type           = Win32.INPUT_KEYBOARD;
            input.ki.wScan       = 0;
            input.ki.wVk         = (Byte)key;
            input.ki.dwFlags     = (UInt16)(isUp ? Win32.KEYEVENTF_KEYUP : 0);
            input.ki.dwExtraInfo = InputExtraInfoValue;

            Win32.INPUT[] inputsArr = new Win32.INPUT[1];
            inputsArr[0] = input;

            return(Win32.SendInput((UInt32)inputsArr.Length, inputsArr, Marshal.SizeOf(typeof(Win32.INPUT))));
        }
Exemplo n.º 4
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="isUp"></param>
        /// <param name="keyInput"></param>
        public static UInt32 SendInput(Boolean isUp, Keys key)
        {
            Debug.WriteLine("SendInput: " + key.ToString() + " ( " + (isUp ? "Up" : "Down" ) + ")");
            Win32.INPUT input = new Win32.INPUT();
            input.ki = new Win32.KEYBDINPUT();
            input.type = Win32.INPUT_KEYBOARD;
            input.ki.wScan = 0;
            input.ki.wVk = (Byte)key;
            input.ki.dwFlags = (UInt16)(isUp ? Win32.KEYEVENTF_KEYUP : 0);
            input.ki.dwExtraInfo = InputExtraInfoValue;

            Win32.INPUT[] inputsArr = new Win32.INPUT[1];
            inputsArr[0] = input;

            return Win32.SendInput((UInt32)inputsArr.Length, inputsArr, Marshal.SizeOf(typeof(Win32.INPUT)));
        }