I just found the solution.
I didn't know about tab concept. The key point was tab handle, the real handle for key processing. If I use main window handle, it can process WM_CLOSE WM_SETTEXT (also SetWindowText(string)) but not WM_KEYDOWN. I imagined the sequence.
- keyboard stroke
- key event to the handle (main window handle)
- handle gives to received event WM_KEYDOWN / WM_CHAR / WM_KEYUP with VK_*
So I must find the tab handle first.
int getTabHandle() {
int hwnd = 0;
hwnd = FindWindowEx(hwnd , 0, "iexplore.exe", null);
hwnd = FindWindowEx(hwnd , 0, "IEFrame", null);
hwnd = FindWindowEx(hwnd , 0, "Frame Tab", null);
hwnd = FindWindowEx(hwnd , 0, "TabWindowClass", null);
hwnd = FindWindowEx(hwnd , 0, "Shell DocObject View", null);
hwnd = FindWindowEx(hwnd , 0, "Internet Explorer_Server", null);
return hwnd;
}
With this hwnd, I could send key without focus. Thanks.