Загрузка данных


@echo off
setlocal
rem Language switch hotkey: each run flips Alt+Shift / Ctrl+Shift
set "KEY=HKCU\Keyboard Layout\Toggle"
set "CUR=1"

rem Value name has a space, so the data itself is the 4th token
for /f "tokens=4" %%a in ('reg query "%KEY%" /v "Language Hotkey" 2^>nul ^| findstr "REG_"') do set "CUR=%%a"

if "%CUR%"=="2" (
    set "NEW=1"
    set "NAME=Alt+Shift"
) else (
    set "NEW=2"
    set "NAME=Ctrl+Shift"
)

reg add "%KEY%" /v "Language Hotkey" /t REG_SZ /d %NEW% /f >nul
reg add "%KEY%" /v "Hotkey" /t REG_SZ /d %NEW% /f >nul

rem Try to apply it right away, without signing out
powershell -NoProfile -Command "Add-Type -Namespace W -Name U -MemberDefinition '[DllImport(\"user32.dll\")] public static extern bool SystemParametersInfo(uint a,uint b,IntPtr c,uint d);'; [void][W.U]::SystemParametersInfo(0x5B,0,[IntPtr]::Zero,0)" >nul 2>&1

echo Was: %CUR%  (1 = Alt+Shift, 2 = Ctrl+Shift)
echo Now: %NAME%
echo.
reg query "%KEY%"
echo.
echo If the old hotkey still works, sign out and sign in again.
pause