Pages

joi, 26 martie 2026

Tools : remove language keyboard with powewrshell.

Simple powershell script with graphic user interface for remove language keyboard. I used copilot artificial intelligence to help me to create this powershell script.
Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing

# ============================
# STARTUP MESSAGE
# ============================
[System.Windows.Forms.MessageBox]::Show(
"Run this script as Administrator.

If scripts are blocked, run:
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass",
"IMPORTANT",
"OK",
"Information"
)

# ============================
# GET INSTALLED LANGUAGES
# ============================
$languages = Get-WinUserLanguageList

# Build a list of IMTs with language names
$imtList = @()

foreach ($lang in $languages) {
    foreach ($imt in $lang.InputMethodTips) {
        $entry = [PSCustomObject]@{
            LanguageName = $lang.Autonym
            LanguageTag  = $lang.LanguageTag
            IMT          = $imt
        }
        $imtList += $entry
    }
}

# ============================
# BUILD THE FORM
# ============================
$form = New-Object System.Windows.Forms.Form
$form.Text = "Keyboard Layout Selector"
$form.Size = New-Object System.Drawing.Size(520, 600)
$form.StartPosition = "CenterScreen"

$label = New-Object System.Windows.Forms.Label
$label.Text = "Select the keyboard layouts you want to KEEP:"
$label.AutoSize = $true
$label.Location = New-Object System.Drawing.Point(10,10)
$form.Controls.Add($label)

$panel = New-Object System.Windows.Forms.Panel
$panel.Location = New-Object System.Drawing.Point(10,40)
$panel.Size = New-Object System.Drawing.Size(480,460)
$panel.AutoScroll = $true
$form.Controls.Add($panel)

$checkboxes = @()
$y = 10

foreach ($item in $imtList) {
    $cb = New-Object System.Windows.Forms.CheckBox
    $cb.Text = "$($item.LanguageName)  |  $($item.LanguageTag)  |  $($item.IMT)"
    $cb.Location = New-Object System.Drawing.Point(10, $y)
    $cb.AutoSize = $true
    $panel.Controls.Add($cb)
    $checkboxes += $cb
    $y += 30
}

$button = New-Object System.Windows.Forms.Button
$button.Text = "Apply"
$button.Location = New-Object System.Drawing.Point(200,520)
$button.Size = New-Object System.Drawing.Size(100,30)
$form.Controls.Add($button)

# ============================
# APPLY BUTTON LOGIC
# ============================
$button.Add_Click({
    $selectedIMTs = @()

    foreach ($cb in $checkboxes) {
        if ($cb.Checked) {
            # Extract IMT from checkbox text
            $parts = $cb.Text.Split("|")
            $imt = $parts[2].Trim()
            $selectedIMTs += $imt
        }
    }

    if ($selectedIMTs.Count -eq 0) {
        [System.Windows.Forms.MessageBox]::Show("You must select at least one layout to keep.")
        return
    }

    # Build new language list
    $newList = @()

    foreach ($lang in $languages) {
        $newLang = New-WinUserLanguageList $lang.LanguageTag
        $newLang[0].InputMethodTips.Clear()

        foreach ($imt in $lang.InputMethodTips) {
            if ($selectedIMTs -contains $imt) {
                $newLang[0].InputMethodTips.Add($imt)
            }
        }

        if ($newLang[0].InputMethodTips.Count -gt 0) {
            $newList += $newLang[0]
        }
    }

    Set-WinUserLanguageList $newList -Force

    [System.Windows.Forms.MessageBox]::Show("Keyboard layouts updated successfully.")
    $form.Close()
})

# ============================
# SHOW FORM
# ============================
$form.ShowDialog()

News : Building Autonomous Networks with Agentic AI.

News : Microsoft Flight Simulator | Local Legend 23: The Fokker F27 Friendship

News : Farming Simulator 26: Announcement Trailer

News : April 24 onward on GitHub.

From April 24 onward, interaction data—specifically inputs, outputs, code snippets, and associated context—from Copilot Free, Pro, and Pro+ users will be used to train and improve our AI models unless they opt out.
  • Install Copilot in your editor;
  • Chat with Copilot anywhere;
  • Start building with Copilot - Learn how to build with Copilot in Visual Studio Code or Visual Studio.