Posts

Showing posts with the label postmessage

How to send WM_INPUTLANGCHANGEREQUEST to app with modal window?

How to send WM_INPUTLANGCHANGEREQUEST to app with modal window? I wrote a keyboard switcher, which works well, but fails if current application has modal window opened. On keyboard switch I do the following hwnd = GetForegroundWindow(); PostMessage(hwnd, WM_INPUTLANGCHANGEREQUEST, IntPtr.Zero, handle); where [DllImport("User32.dll", EntryPoint = "PostMessage")] private static extern int PostMessage(IntPtr hWnd, int Msg, IntPtr wParam, IntPtr lParam); [DllImport("user32.dll")] static extern IntPtr GetForegroundWindow(); but the language does not change. How would I accomplish this? Adding get root owner improved situation, but didn't help completely. Adding call for GetDesktopWindow didn't help: GetDesktopWindow hwnd = GetDesktopWindow(); InputLangChangeRequest(hwnd, language); hwnd = GetRootOwner(); InputLangChangeRequest(hwnd, language); Code is here https://github.com/dims12/NormalKeyboardSwitcher Possible duplicate o...