How can I simulate Alt+Shift to change the language in Windows (II part)?
The problem (switching language dynamically) is solved with ActivateKeyboardLayout, but it still remains when i dynamically create a compon开发者_JS百科ent on the form ( for ex. TEdit ). When this component gets into focus, the language changes to default. I tried use again ActivateKeyboardLayout, after creating the components, but it did not worked. Any ideas ?
at first you have to use "Windows" then you can use this method: ActivateKeyboardLayout(EnglishLayoutHandle, KLF_ACTIVATE) you can change "EnglishLayoutHandle" for any lang you want
Your problem may be similar to this question.
Otherwise this code does it:
keybd_event(VK_MENU, 0, 0, 0);
keybd_event(VK_SHIFT, 0, 0, 0);
keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0 );
keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
On the Console application use
HWND handle = GetForegroundWindow();
PostMessage(handle, WM_INPUTLANGCHANGEREQUEST,
0, (LPARAM)HKL_NEXT);
精彩评论