none
Changing keyboard layout in Word RRS feed

  • Question

  • Dear All

    I have been able to change the Input language in my word Addin but there are two problems

    1. I am using a dropdown list of languages to select and change the input language programmatically in word addin. It works fine. If the user changes the input language using Alt+Shift then the language is changed. I want to reflect that change in my dropdown as well. Because otherwise my selected input language and system's input languages are different. How to capture language change done using Alt+Shift key.

    2. One language may have many keyboards (Layouts) associated with it. I have been able to get different layouts for a selected language. But can't find the way of changing the keyboard layout for the selected language. How to do this? Please suggest.

    Thanks in advance.

    Regards


    Dharam Veer Sharma

    Friday, January 9, 2015 5:31 AM

Answers

  • Thanks Eugene

    I have been able to do this using a crude method, the code is as under

        Dim KBName As String = ddKeyboards.SelectedItem.Label
                For Each lang In InputLanguage.InstalledInputLanguages
                    If lang.LayoutName = KBName Then
                        InputLanguage.CurrentInputLanguage = lang
                        Exit For
                    End If
                Next lang

    Here ddKeyboards (dropdown) contains the list of installed keyboards for different languages. It's working perfectly.


    Dharam Veer Sharma

    Friday, January 9, 2015 6:44 PM

All replies

  • Hello Dharam,

    1. VSTO doesn't provide anything for that out of the box. You need to set up a keyboard hook using the SetWindowsHookEx function (Windows API). See Using shortcut keys to call a function in an Office Add-in for more information.

    2. You may find the How to change Input Language programmatically? article helpful.

    Friday, January 9, 2015 5:47 PM
  • Thanks Eugene

    I have been able to do this using a crude method, the code is as under

        Dim KBName As String = ddKeyboards.SelectedItem.Label
                For Each lang In InputLanguage.InstalledInputLanguages
                    If lang.LayoutName = KBName Then
                        InputLanguage.CurrentInputLanguage = lang
                        Exit For
                    End If
                Next lang

    Here ddKeyboards (dropdown) contains the list of installed keyboards for different languages. It's working perfectly.


    Dharam Veer Sharma

    Friday, January 9, 2015 6:44 PM