<p>I'm writing a program in C# that runs in the background and allows users to use a hotkey to switch keyboard layouts in the active window.  (Windows only supports <kbd>CTRL</kbd>+<kbd>SHIFT</kbd> and <kbd>ALT</kbd>+<kbd>SHIFT</kbd>)</p>

<p>I'm using RegisterHotKey to catch the hotkey, and it's working fine.</p>

<p>The problem is that I can't find any API to change the keyboard layout for the focused window.</p>

<p>ActivateKeyboardLayout and LoadKeyboardLayout  can only change the keyboard layout for the calling thread.</p>

<p>Does anyone know how to change the keyboard layout for a different thread (the way the Language Bar does)?</p>

I think the trick is to get your code to execute in the context of the thread whose keyboard layout you wish to change. You'll need to do some win32 interop here and learn about DLL Injection to get your code to execute in the remote thread.
A
keyboard hook handler
looks like a good option for you here.
Take a look at
http://www.codeproject.com/KB/threads/winspy.aspx