Send Ctrl+Up to a window
- by dutt
I'm trying to send messages to a window that says Ctrl and Up-arrow has been pressed. I've got the basics down, I can send presses of the space key that registeres fine. But I can't seem to get the ctrl+up working.
chosen code snippets:
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
static extern IntPtr SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);
Now this works fine for sending Space:
public static void SendKeyPress(IntPtr handle, VKeys key)
{
SendMessage(handle, (int) WMessages.WM_KEYDOWN, (int) key, 0);
SendMessage(handle, (int)WMessages.WM_KEYUP, (int)key, 0);
}
But this doesn't work for sending Ctrl+Up:
public static void SendKeyPress(IntPtr handle, VKeys key, bool control)
{
SendMessage(handle, (int) WMessages.WM_KEYDOWN, (int) key, 0);
SendMessage(handle, (int) WMessages.WM_KEYDOWN, (int)VKeys.VK_CONTROL, 0);
SendMessage(handle, (int)WMessages.WM_KEYUP, (int)key, 0);
SendMessage(handle, (int)WMessages.WM_KEYUP, (int)VKeys.VK_CONTROL, 0);
}
What am I missing?