6

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.

Gilles 'SO- stop being evil'
  • 104,111
  • 38
  • 209
  • 254
yanivps
  • 1,993
  • 3
  • 25
  • 33

2 Answers2

2

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);
    }
Dims
  • 47,675
  • 117
  • 331
  • 600
1

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

Community
  • 1
  • 1
John Sykor
  • 727
  • 5
  • 15