- 1 year ago
How to change keyboard language if a specific keyboard is connected? (Win 10/11)
Comment
1 / 1
To change the keyboard language automatically when a specific keyboard is connected in Windows 10/11, you can use a combination of PowerShell and Task Scheduler. Here's how you can set it up:
Identify the keyboard identifier:
- Connect the specific keyboard to your computer.
- Open PowerShell by pressing the Windows key + X and selecting "Windows PowerShell" or "Windows PowerShell (Admin)".
- Run the following command to retrieve the keyboard identifier:powershell
Get-WmiObject Win32_Keyboard | Select-Object DeviceID, Description
- Note down the DeviceID value associated with your specific keyboard. This identifier will help determine if the keyboard is connected or disconnected.
Create a PowerShell script:
- Create a new PowerShell script file with a
.ps1
extension using a text editor. - In the script file, add the following code to change the keyboard language:powershell
$keyboardIdentifier = "YOUR_KEYBOARD_DEVICE_ID" # Replace with the DeviceID of your specific keyboard
$desiredLanguage = "LANGUAGE_CODE" # Replace with the language code you want to switch to
$keyboard = Get-WmiObject Win32_Keyboard | Where-Object { $_.DeviceID -eq $keyboardIdentifier }
if ($keyboard -ne $null) {
$keyboardLanguage = Get-WinUserLanguageList | Where-Object { $_.InputMethodTips -contains $desiredLanguage }
if ($keyboardLanguage -ne $null) {
$keyboardLanguage.Activate()
}
}
- Replace
"YOUR_KEYBOARD_DEVICE_ID"
with the DeviceID of your specific keyboard obtained in step 1. - Replace
"LANGUAGE_CODE"
with the language code (e.g., "en-US" for English) you want to switch to when the keyboard is connected.
- Create a new PowerShell script file with a
Test the PowerShell script:
- Save the PowerShell script.
- Open a PowerShell terminal and run the script. Ensure that the desired keyboard language is activated when the specific keyboard is connected.
Create a scheduled task:
- Open Task Scheduler by pressing the Windows key + X and selecting "Task Scheduler."
- Click on "Create Task" to open the Create Task window.
- In the General tab, give the task a name and select "Run whether the user is logged on or not."
- In the Triggers tab, click "New" and choose "On connection" as the trigger. Select "Any connection" or specify a specific user if required.
- In the Actions tab, click "New" and select "Start a program." Browse and select the
powershell.exe
executable, and set the arguments to the path of the PowerShell script you created in step 2. - Click "OK" to save the task.
Test the scheduled task:
- Disconnect and reconnect the specific keyboard to trigger the scheduled task.
- Verify that the keyboard language changes to the desired language automatically.
By following these steps, you can automate the process of changing the keyboard language when a specific keyboard is connected in Windows 10/11.