This extends the "Change My-T-Soft Layout" example at How to externally Change My-T-Soft Layout. The first part below explains the mechanism provided by Windows, and then it ties into the example of the linked example above.
There is an unattended XMLfeature that can be used to manipulate regional and language settings. This example only uses the InputPreferences option, and there are many other aspects to this functionality that are not covered here. The example is from Windows 7. This also works for Windows 10, but the default input layout acts differently - note that [Win]-[Space] will roll through current input layouts.
This is an Example of an XML file that adds and removes layouts using Spanish, English US, and German layouts, setting English as the default
<gs:GlobalizationServices xmlns:gs="urn:longhornGlobalizationUnattend">
<!-- User List -->
<gs:UserList>
<gs:User UserID="Current" />
</gs:UserList>
<gs:InputPreferences>
<!-- Spanish -->
<gs:InputLanguageID Action="remove" ID="0c0a:0000040a" Default="false" />
<!-- en-US -->
<gs:InputLanguageID Action="add" ID="0409:00000409" Default="true" />
<!-- de-DE -->
<gs:InputLanguageID Action="add" ID="0407:00000407" Default="false" />
</gs:InputPreferences>
</gs:GlobalizationServices>
This file would need to be saved as an XML file, e.g. inputchange.xml, and care must be taken to make sure standard characters are used (text only type file), and then it can be implemented using the following:
control intl.cpl,, /f:"inputchange.xml"
Note: There are 2 commas, and there needs to be a space between the second comma and the /f switch. The quotes need to be normal double-quotes, and ideally a path would be specified - this example must be run from the same directory where the file inputchange.xml exists. The critical piece is the ID value for the InputLanguageID - refer to Microsoft documentation for additional ID values for language, region, and layout.
To use these tools, 4 XML files where created that do discrete actions - add and remove Italian and Japanese layouts. By removing the layout, if it is the default in an open application, it will be replaced by the new default layout. It is important to note how Windows handles input layouts - each Window can have its own input settings, and by changing focus between open applications, the current input language will stay with the current settings for an open Window. For example, you could have 3 instances of Notepad open, and each could have their own input language, and the keyboard layout will change based on which Notepad is the current active window. There are options for the input language to show on the task bar or as a floating window to indicate which input language is active. Note that most users set to the current locale, and operate with 1 input locale, so the issues of changing input settings would typically not apply, but when changing and working with multiple input locales, unique situations can occur, so awareness of which input locale is in use can be extremely relevant and useful.
IT.XML - Adds Italian (Italy) layout and sets as default
<gs:GlobalizationServices xmlns:gs="urn:longhornGlobalizationUnattend">
<!-- User List -->
<gs:UserList>
<gs:User UserID="Current"/>
</gs:UserList>
<gs:InputPreferences>
<!-- Italian -->
<gs:InputLanguageID Action="add" ID="0410:00000410" Default="true"/>
</gs:InputPreferences>
</gs:GlobalizationServices>
ITREMOVE.XML - Removes Italian layout
<gs:GlobalizationServices xmlns:gs="urn:longhornGlobalizationUnattend">
<!-- User List -->
<gs:UserList>
<gs:User UserID="Current"/>
</gs:UserList>
<gs:InputPreferences>
<!-- Italian -->
<gs:InputLanguageID Action="remove" ID="0410:00000410"/>
</gs:InputPreferences>
</gs:GlobalizationServices>
JP.XML - Adds Japanese layout and sets as default
<gs:GlobalizationServices xmlns:gs="urn:longhornGlobalizationUnattend">
<!-- User List -->
<gs:UserList>
<gs:User UserID="Current"/>
</gs:UserList>
<gs:InputPreferences>
<!-- JP-Japanese -->
<gs:InputLanguageID Action="add" ID="0411:{03B5835F-F03C-411B-9CE2-AA23E1171E36}{A76C93D9-5523-4E90-AAFA-4DB112F9AC76}" Default="true"/>
</gs:InputPreferences>
</gs:GlobalizationServices>
JPREMOVE.XML - Removes Japanese layout
<gs:GlobalizationServices xmlns:gs="urn:longhornGlobalizationUnattend">
<!-- User List -->
<gs:UserList>
<gs:User UserID="Current"/>
</gs:UserList>
<gs:InputPreferences>
<!-- JP-Japanese -->
<gs:InputLanguageID Action="remove" ID="0411:{03B5835F-F03C-411B-9CE2-AA23E1171E36}{A76C93D9-5523-4E90-AAFA-4DB112F9AC76}"/>
</gs:InputPreferences>
</gs:GlobalizationServices>
The following extends the batch file from the example linked at the top of this item
@echo off
cls
REM This toggles 2 layouts.
REM These files must exist:
REM JAPAN.CFG and JAPAN.INI for Japanese layout
REM ITALIAN.CFG and ITALIAN.INI for Italian layout
REM If changing Layouts, the it, itremove, jp, and jpremove XML files must exist
REM user is [Username] for current logged in user / application user
REM the actual path below is an example, will need to be updated for your usage
REM If the Input Language layout is not changing as expected, you may find events
REM that may show errors or warnings in the Event Viewer.
REM Go to Control Panel | System and Security | Administrative Tools | View Event Logs
REM and in the Event Viewer open Applications and Services Logs then go into
REM Microsoft | Windows | International and view the Operational log
C:
cd "C:\Users\user\AppData\Roaming\Innovation Management Group\MYTSOFT"
IF exist LAYOUTJAPAN.CUR GOTO DOITALIAN
REM This changes the My-T-Soft Layout
cpycnmts.exe JAPAN.CFG
REM This removes Italian Input Resource
control intl.cpl,, /f:"itremove.xml"
REM This adds & sets as default the Japanese Input Resource
control intl.cpl,, /f:"jp.xml"
copy JAPAN.CFG LAYOUTJAPAN.CUR
goto END
:DOITALIAN
REM This changes the My-T-Soft Layout
cpycnmts.exe ITALIAN.CFG
REM This removes Japanese Input Resource
control intl.cpl,, /f:"jpremove.xml"
REM This adds and sets as default the Italian Input Resource
control intl.cpl,, /f:"it.xml"
DEL LAYOUTJAPAN.CUR
:END
Notes:
- The add/remove settings could reside in a single XML file, but for clarity each step is done independently.
- Permissions and UIPI issues can limit system level changes - reference first part of example (link at top) and test as Administrator if limited user is not changing layouts as desired.
- If Input Layouts do not change, check Event Viewer (specific log referenced above in batch file) for potential text or syntax issues
- Testing with Administrator Command Prompt may be helpful
- This example adds/removes only the specified languages - it may be desirable to only have a single input layout in use, but care must be taken in ensuring there is at least 1 input layout available.
- The Japanese InputLanguageID uses GUID codes - for Asian languages past Windows 7, the GUID ID= settings are required - reference Microsoft documentation for other language identifiers
- Japanese uses an IME (Input Method Editor), and you may need to select Hiragana as the input method. If you are not familiar with the Hiragana input method, it should be noted that Latin characters (Romaji) may appear (use space bar for viewing input candidates) - using the Layout indicator on the Taskbar or as a floating window is the definitive way to determine what the current input layout/method is set at.
- This approach can be extended to additional languages as needed - reference Microsoft IDs based on current version of Windows
- These XML files just touch upon some of the capabilities of the unattended GlobalSettings changes. There are ways to change values for the system or other users, many more settings, and other options that are not covered here - this only uses the option to add and set as default the current input layout
Category: Integrating(Developing) | Type: Question/Answer | Product: My-T-Soft | Version: 1.78 1.79 1.80 1.90 |
Notes:
As seen in ...