Skip to content

Commit

Permalink
INPUTLANGCHANGEREQUEST target fix. Still not working in skype
Browse files Browse the repository at this point in the history
  • Loading branch information
kurumpa committed Oct 24, 2014
1 parent a561b8f commit 7e3936e
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion LowLevelAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,20 @@ public static void ReleaseMouseHook(HookId id)

public static void SetNextKeyboardLayout()
{
PostMessage(GetForegroundWindow(), WM_INPUTLANGCHANGEREQUEST, INPUTLANGCHANGE_FORWARD, HKL_NEXT);
// if (gti.hwndFocus! =0)
// wnd = gti.hwndFocus;
//else
// wnd = gti.hwndActive;
IntPtr hWnd = GetForegroundWindow();
uint processId;
uint activeThreadId = GetWindowThreadProcessId(hWnd, out processId);
uint currentThreadId = GetCurrentThreadId();

AttachThreadInput(activeThreadId, currentThreadId, true);
IntPtr focusedHandle = GetFocus();
AttachThreadInput(activeThreadId, currentThreadId, false);

PostMessage(focusedHandle == IntPtr.Zero ? hWnd : focusedHandle, WM_INPUTLANGCHANGEREQUEST, INPUTLANGCHANGE_FORWARD, HKL_NEXT);
}

private static IntPtr ProcessKeyPress(IntPtr hookResult, int nCode, IntPtr wParam, IntPtr lParam, Action<HookEventData> cb)
Expand Down

0 comments on commit 7e3936e

Please sign in to comment.