SendInput scan code on Windows 7 x64
Posted
by Stanomatic
on Stack Overflow
See other posts from Stack Overflow
or by Stanomatic
Published on 2010-03-26T05:55:15Z
Indexed on
2010/03/26
6:13 UTC
Read the original article
Hit count: 356
I am working with a WPF application sending keys to a game. I opened spy++ to observer s as a key press on the keyboard. I then press my button on the application and I noticed a different scan code in spy++ messages. Could this be somthing to do with Windows 7 64bit? Partial listing:
var down = new INPUT();
down.Type = (UInt32)InputType.KEYBOARD;
down.Data.Keyboard = new KEYBDINPUT();
down.Data.Keyboard.Vk = (UInt16)keyCode;
down.Data.Keyboard.Scan = 0;
down.Data.Keyboard.Flags = 0;
down.Data.Keyboard.Time = 0;
down.Data.Keyboard.ExtraInfo = IntPtr.Zero;
//down.Data.Keyboard.ExtraInfo = GetMessageExtraInfo();
var up = new INPUT();
up.Type = (UInt32)InputType.KEYBOARD;
up.Data.Keyboard = new KEYBDINPUT();
up.Data.Keyboard.Vk = (UInt16)keyCode;
up.Data.Keyboard.Scan = 0;
up.Data.Keyboard.Flags = (UInt32)KeyboardFlag.KEYUP;
up.Data.Keyboard.Time = 0;
up.Data.Keyboard.ExtraInfo = IntPtr.Zero;
//up.Data.Keyboard.ExtraInfo = GetMessageExtraInfo();
INPUT[] inputList = new INPUT[2];
inputList[0] = down;
inputList[1] = up;
var numberOfSuccessfulSimulatedInputs = SendInput(2, inputList, Marshal.SizeOf(typeof(INPUT)));
The image shows when I use my code to send a key I receive ScanCode:00fExtended from spy++ message output. When I actually press the same key I receive ScanCode:1FfExtended. Everything else is identical.
© Stack Overflow or respective owner