Created
May 16, 2020 01:50
-
-
Save kusa-mochi/82c3c2a65cf4bb3c560ec56f4029e594 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// キーコード | |
short key = 65; | |
INPUT[] inputs = new INPUT[] { | |
new INPUT { | |
type = NativeMethods.INPUT_KEYBOARD, | |
ui = new INPUT_UNION { | |
keyboard = new KEYBDINPUT { | |
wVk = key, | |
wScan = (short) NativeMethods.MapVirtualKey (key, 0), | |
dwFlags = NativeMethods.KEYEVENTF_EXTENDEDKEY | NativeMethods.KEYEVENTF_KEYDOWN, // キーの押し下げ | |
dwExtraInfo = IntPtr.Zero, | |
time = 0 | |
} | |
} | |
}, | |
new INPUT { | |
type = NativeMethods.INPUT_KEYBOARD, | |
ui = new INPUT_UNION { | |
keyboard = new KEYBDINPUT { | |
wVk = key, | |
wScan = (short) NativeMethods.MapVirtualKey (key, 0), | |
dwFlags = NativeMethods.KEYEVENTF_EXTENDEDKEY | NativeMethods.KEYEVENTF_KEYUP, // キーの押し上げ | |
dwExtraInfo = IntPtr.Zero, | |
time = 0 | |
} | |
} | |
} | |
}; | |
NativeMethods.SendInput (2, ref inputs[0], Marshal.SizeOf (inputs[0])); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment