/// <summary> /// SendInput Win32APIをラップしたメソッド /// </summary> /// <param name="inputs"></param> public static void SendInput(INPUT[] inputs) { for (Int32 i = 0; i < inputs.Length; i++) { INPUT input = inputs[i]; if (input.type == type.INPUT_KEYBOARD) { //キーボードの時は変換が必要らしい //input.ki.wScan = (Int16)input.ki.wVk;//(Int16)(MapVirtualKey((Int32)input.ki.wVk, 0)); input.ki.dwExtraInfo = GetMessageExtraInfo(); input.ki.dwFlags = ExtendedKeyFlagW(input.ki.wVk) | input.ki.dwFlags; } } SendInput(inputs.Length, inputs, Marshal.SizeOf(inputs[0])); }
public static extern uint SendInput(uint nInputs, ref INPUT pInputs, int cbSize);
private extern static Int32 SendInput(Int32 nInputs, INPUT[] pInputs, Int32 cbSize);
public static void SendInput(INPUT input) { input.ki.dwExtraInfo = GetMessageExtraInfo(); input.ki.dwFlags = ExtendedKeyFlagW(input.ki.wVk) | input.ki.dwFlags; SendInput(1, ref input, Marshal.SizeOf(input)); }