private void OnMenuItemClicked(object sender, EventArgs e)
        {
            ToolStripMenuItem item       = (ToolStripMenuItem)sender;
            var selectedKeyboardLayoutId = (UInt32)item.Tag;

            foreach (KeyboardLayout layout in keyboardLayouts)
            {
                if (layout.Id == selectedKeyboardLayoutId)
                {
                    inputKeyboardLayout = layout;
                    break;
                }
            }

            setKeyboardLayoutIdToConfig(selectedKeyboardLayoutId);
        }
        private void setupInputKeyboardLayout()
        {
            var keyboardLayoutId = configKeyboardLayoutId();

            foreach (KeyboardLayout layout in keyboardLayouts)
            {
                if (layout.Id == keyboardLayoutId)
                {
                    inputKeyboardLayout = layout;
                    break;
                }
            }

            if (inputKeyboardLayout == null)
            {
                inputKeyboardLayout = defaultKeyboardLayout();
                setKeyboardLayoutIdToConfig(inputKeyboardLayout.Id);
            }
        }
        public static void switchForegroundWindowKeyboardLayout(KeyboardLayout layout)
        {
            IntPtr hwnd = GetForegroundWindow();

            PostMessage(hwnd, 0x0050, IntPtr.Zero, (IntPtr)layout.KeyboardId);
        }