Hi!
I've been trying to send Ctrl+s to notepad, but havent succesfully manage to do this. I've googled it, but havent found anyone who have sent a ctrl+letter command to a process.
Currently, the sending part of my code look like this:
Code:
IntPtr hWnd = FindWindow("Notepad", null);
IntPtr hWndChild = FindWindowEx(hWnd, IntPtr.Zero, "Edit", null);
int VK_CONTROL = (int)0x11;
uint wm_keydown = (uint)0x100;
uint wm_char = (uint)0x102;
uint wm_keyup = (uint)0x101;
PostMessage(hWndChild, wm_keydown, VK_CONTROL, 0); //Send Ctrl down
PostMessage(hWndChild, wm_keydown, VkKeyScan('s'), 0); //Send 's' down
PostMessage(hWndChild, wm_keyup, VkKeyScan('s'), 0); //Send 's' up
PostMessage(hWndChild, wm_keyup, VK_CONTROL, 0); //Send Ctrl up
I've also tried different values for the lParam parameter (taken from Spy++) and to use hWnd instead of hWndChild, but it does not work. Does anyone know any way to send Ctrl+s to notepad using PostMessage (or SendMessage)? I would really appreciate if anyone could post some sample code. Thank you!