コード例 #1
0
        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);
        }
コード例 #2
0
        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);
            }
        }
コード例 #3
0
        public static void switchForegroundWindowKeyboardLayout(KeyboardLayout layout)
        {
            IntPtr hwnd = GetForegroundWindow();

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