void CCalcsylDlg::OnTestNotepad()
{
// TODO: Add your control notification handler code here
HWND w1;
w1=::FindWindow("Notepad",NULL);
w1=::FindWindowEx(w1,NULL,"Edit",NULL);
::SendMessage(w1,WM_CHAR,'A',0); /* 可以成功的模拟字符A */
::SendMessage(w1,WM_KEYDOWN,VK_CONTROL,0);
::SendMessage(w1,WM_KEYDOWN,'A',0);
::SendMessage(w1,WM_KEYUP,'A',0);
::SendMessage(w1,WM_KEYUP,VK_CONTROL,0);
}
使用spy++看了一下,就是两个KEYDOWN,两个KEYUP消息,但上述代码不能模拟按键ctrl-a