I'm trying to write an application that going to proccess and send him the keystrokes ctrl-a and then ctrl-c that i will have the text content in my clipboard.
I read that the correct api is PostMessage
`Sendmeesage`.
with the api i success to write into a program (notepad for example).
but I didnt success to send keystrokes.
here is my code
public const uint WM_KEYDOWN = 0x0100;
public const uint WM_KEYUP = 0x0101;
const int CTRL = 0x11;
const int A_Key = 0x41;
const int C_Key = 0x43;
static void Main(string[] args)
{
IntPtr hWnd = FindWindow(null, "Microsoft Word ");
hWnd = FindWindowEx(hWnd, null, "Edit", null);
//PostMessage(hWnd, WM_GETTEXT, 0x11, 0);
Process[] processes = Process.GetProcessesByName("winword");
foreach (Process p in processes)
{
PostMessage((IntPtr)hWnd, WM_KEYDOWN, (IntPtr)CTRL, 1);
PostMessage((IntPtr)hWnd, WM_KEYDOWN, (IntPtr)A_Key, 1);
PostMessage((IntPtr)hWnd, WM_KEYUP, (IntPtr)A_Key, 1);
PostMessage((IntPtr)hWnd, WM_KEYUP, (IntPtr)CTRL, 1);
}
}
what i'm doing wrong?