主题:[讨论]模拟键盘输入的问题
在“运行”中输入debug进入汇编的debug环境,我写一个程序模拟键盘输入,但总是失败。无论是keybd_event(),sendinput()还是sendmessage(),都没成功,若在记事本中模拟输入没问题。难道....debug有什么不可告人的秘密???求指点。。。
关键代码如下:
HWND cmd=FindWindow(NULL,L"C:\\windows\\system32\\debug.exe");
if(cmd!=NULL)
{
ShowWindow(cmd,SW_NORMAL);
SetForegroundWindow(cmd);
keybd_event(65,0,0,0);
keybd_event(65,0,KEYEVENTF_KEYUP,0);
//PostMessage(cmd,WM_KEYDOWN,'A',0);
//PostMessage(cmd,WM_KEYUP,'A',0);
/*INPUT input;
input.type = INPUT_KEYBOARD;
input.ki.wVk=65;
input.ki.wScan =65;
input.ki.dwFlags = KEYEVENTF_EXTENDEDKEY;
input.ki.dwExtraInfo = NULL;
input.ki.time = 0;
SendInput(1, &input, sizeof(input));
input.ki.dwFlags = KEYEVENTF_EXTENDEDKEY|KEYEVENTF_KEYUP;
SendInput(1, &input, sizeof(input)); */
printf("输入完毕!\n");
}
求大牛啊~~~
关键代码如下:
HWND cmd=FindWindow(NULL,L"C:\\windows\\system32\\debug.exe");
if(cmd!=NULL)
{
ShowWindow(cmd,SW_NORMAL);
SetForegroundWindow(cmd);
keybd_event(65,0,0,0);
keybd_event(65,0,KEYEVENTF_KEYUP,0);
//PostMessage(cmd,WM_KEYDOWN,'A',0);
//PostMessage(cmd,WM_KEYUP,'A',0);
/*INPUT input;
input.type = INPUT_KEYBOARD;
input.ki.wVk=65;
input.ki.wScan =65;
input.ki.dwFlags = KEYEVENTF_EXTENDEDKEY;
input.ki.dwExtraInfo = NULL;
input.ki.time = 0;
SendInput(1, &input, sizeof(input));
input.ki.dwFlags = KEYEVENTF_EXTENDEDKEY|KEYEVENTF_KEYUP;
SendInput(1, &input, sizeof(input)); */
printf("输入完毕!\n");
}
求大牛啊~~~