Change input language of another application

2.2k Views Asked by At

I want to change the input language of the active window. The problem is that the active window is not my application. I know about InputLanguage.CurrentInputLanguage = lang; but it changes the language for my WinForms application and not for the active application.

Summary: my situation is that my program listens to any keyboard event (even when it's not focused) and executes code when I press F1.

I want this press on F1 to change the language to Hebrew in Notepad which was the active application when I pressed F1.

I am interested in either a low level solution or a high level solution.

2

There are 2 best solutions below

0
On

You should know another application's hWnd and post a message for it

    public void InputLangChangeRequest(IntPtr hwnd, InputLanguage language)
    {
        IntPtr handle = InputLanguage.Handle;
        PostMessage(hwnd, WM_INPUTLANGCHANGEREQUEST, IntPtr.Zero, handle);
    }
0
On

This might be a duplicate of this Switch input language on remote application

This reference can also help. http://msdn.microsoft.com/en-us/library/ms724947