I’m using thiis code to simulate key presses or key ups:
[System.Runtime.InteropServices.DllImport("user32.dll")]
public static extern void keybd_event(byte bVk, byte bScan, uint dwFlags, uint dwExtraInfo);
const uint KEYEVENTF_KEYUP = 0x0002;
const uint KEYEVENTF_EXTENDEDKEY = 0x0001;
// Key up
keybd_event((byte)Convert.ToInt32("A0"), 0, KEYEVENTF_KEYUP | 0, 0);
// Key down
keybd_event((byte)Convert.ToInt32("A0"), 0, KEYEVENTF_EXTENDEDKEY | 0, 0);
According to this table, left-shift has the keycode A0.
For some reason the code above isn’t working. Does anyone know why? Thanks a lot for the help! 🙂
If using keycode is not necessary then you can use
Keys.LShiftKeyfrom KEY enumeration of System.Windows.Forms Namespace.Further using
is not a bad idea.