利用 AttachThreadInput 和 WM_INPUTLANGCHANGEREQUEST 消息改变其它进程的输入状态
https://blog.csdn.net/kaizi318/article/details/7766283?utm_medium=distribute.pc_relevant_bbs_down.none-task-blog-baidujs-1.nonecase&depth_1-utm_source=distribute.pc_relevant_bbs_down.none-task-blog-baidujs-1.nonecase
https://stackoverflow.com/questions/24319987/delphi-simulate-key-press-for-automation
https://www.it1352.com/2041624.html
c# AttachThreadInput WM_INPUTLANGCHANGEREQUEST
HWND hWnd = GetForegroundWindow(); ASSERT(IsWindow(hWnd)) // Get Target Thread ID and Attach Thread Input DWORD ProcID; DWORD ThreadID = GetWindowThreadProcessId(hWnd, &ProcID); AttachThreadInput(GetCurrentThreadId(), ThreadID, TRUE); // Get Target Window HWND hWndFocus = GetFocus(); // Post Input Messages ASSERT(IsWindow(hWndFocus)); // Change Input Language PostMessage(hWndFocus, WM_INPUTLANGCHANGEREQUEST, (WPARAM)TRUE, (LPARAM)g_hklRPC); // Use Language ID 0x0804(Chinese PRC) // Detach Thread Input AttachThreadInput(GetCurrentThreadId(), ThreadID, FALSE);