Hi there:
I met with one problem. I try to send a simulated keystroke to another application (such as Notepad) to invoke one of its functions, but when I minimize the window of "Notepad", the message cannot be received even I used the SetFocus() and SetActiveWindow() function. When it is maximized, it works. Anyone can help? Here are my codes:
int main( )
{
HWND hwnd = FindWindow(NULL, "Untitled - Notepad");
short f3_key = VK_F3;
UINT scancode = MapVirtualKey(f3_key, 0);
if (hwnd!=NULL){
printf("Notepad is running!\n");
SetActiveWindow(hwnd);
SetFocus(hwnd);
}
PostMessage(hwnd, WM_SYSKEYDOWN, f3_key, scancode);
PostMessage(hwnd, WM_SYSCHAR, f3_key, scancode);
PostMessage(hwnd, WM_SYSKEYUP, f3_key, scancode);
return 0;
}
Do you Yahoo!?
Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes