Hi,
I posted the full question on StackOverFlow:
http://stackoverflow.com/questions/3554171/cant-send-a-single-key-function-to-remote-desktop
long story short:
im able to send text to the remote computer but not single key strokes (meaning as keys, not as a string).
i think the solution is that i need to use the MapVirtualKey method, just dont know how to use is correctly...
in this example the scan code is 0, i assume it suppose to be the return value of MapVirtualKey...
if you could please help me with this example and ill be on my way:
public static void SimulateKeyDown(VirtualKeyCode keyCode)
{
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;
INPUT[] inputList = new INPUT[1];
inputList[0] = down;
var numberOfSuccessfulSimulatedInputs = SendInput(1, inputList, Marshal.SizeOf(typeof(INPUT)));
if (numberOfSuccessfulSimulatedInputs == 0) throw new Exception(string.Format("The key down simulation for {0} was not successful.", keyCode));
}
many Thanks Ahead,
Niv.
I posted the full question on StackOverFlow:
http://stackoverflow.com/questions/3554171/cant-send-a-single-key-function-to-remote-desktop
long story short:
im able to send text to the remote computer but not single key strokes (meaning as keys, not as a string).
i think the solution is that i need to use the MapVirtualKey method, just dont know how to use is correctly...
in this example the scan code is 0, i assume it suppose to be the return value of MapVirtualKey...
if you could please help me with this example and ill be on my way:
public static void SimulateKeyDown(VirtualKeyCode keyCode)
{
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;
INPUT[] inputList = new INPUT[1];
inputList[0] = down;
var numberOfSuccessfulSimulatedInputs = SendInput(1, inputList, Marshal.SizeOf(typeof(INPUT)));
if (numberOfSuccessfulSimulatedInputs == 0) throw new Exception(string.Format("The key down simulation for {0} was not successful.", keyCode));
}
many Thanks Ahead,
Niv.