2

Is there a way to open a virtual windows keyboard in Russian while my language setting is Englisch or German?

Can I open a virtual keyboard by a script or any other shortcut in a different language as my current setting? According this info here I can use osk (powershell, cmd), but no chance to set the language.


I found an awkward solution. According to https://superuser.com/a/922767/72397 I can use a different user with the Russian locale.

Then I can use this user to start osk. Because of 740: The requested operation requires elevation I need to work this workaround and fire another cmd first (see https://superuser.com/a/1134561/72397).

So runas /profile /savecred /user:"RUSSIAN USER" "cmd /c start osk" starts the osk with the locale of that specific user.

Edit 2: After some testing I have realized it is not possible to have an OSK different from my current locale, even if the OSK runs as a different user. As soon as I click somewhere on the OSK window it changes its keyboard layout to my locale.

The idea was to have one OSK running in Russian while I am working with a Germany keyboard layout.

So the best solution appears to use the AutohotKey solution, quickly change to Russian and then back.


Private remark, related to SO https://stackoverflow.com/q/74829525/356726

Horst Walter
  • 1,899
  • 7
  • 27
  • 46

1 Answers1

1

You need to use a third-party tool.

You may use the free AutoHotkey.

The following example script will switch the system language to a given installed language and start the on-screen keyboard. Here F11 will set the language to US-English, while F12 will set it to French-Standard. More language codes may be found in the Microsoft article Language Codes.

F11::SetDefaultKeyboard(0x0409) ; english-US
F12::SetDefaultKeyboard(0x040c) ; french

SetDefaultKeyboard(LocaleID){
    Global
    SPI_SETDEFAULTINPUTLANG := 0x005A
    SPIF_SENDWININICHANGE := 2
    Lan := DllCall("LoadKeyboardLayout", "Str", Format("{:08x}", LocaleID), "Int", 0)
    VarSetCapacity(Lan%LocaleID%, 4, 0)
    NumPut(LocaleID, Lan%LocaleID%)
    DllCall("SystemParametersInfo", "UInt", SPI_SETDEFAULTINPUTLANG, "UInt", 0, "UPtr", &Lan%LocaleID%, "UInt", SPIF_SENDWININICHANGE)
    WinGet, windows, List
    Loop %windows% {
        PostMessage 0x50, 0, %Lan%, , % "ahk_id " windows%A_Index%
    }
    Sleep, 100
    Run, C:\Windows\System32\osk.exe
}

After installing AutoHotKey, put the above text in a .ahk file and double-click it to test. You may stop the script by right-click on the green H icon in the traybar and choosing Exit. To have it run on login, place it in the Startup group at
C:\Users\USER-NAME\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup.

Useful AutoHotkey documentation:

harrymc
  • 455,459
  • 31
  • 526
  • 924
  • Thanks, will check that one. Question, would I need to reset to my original keyboard after running that script, or are the changes only within the scope of `SetDefaultKeyboard`? – Horst Walter Dec 15 '22 at 18:50
  • 1
    Thanks, works fine, as assumed changes Keyboard globally. So I need to get a bit into detail and reset the keyboard settings after OSK is opened. I will accept your answer in 1-2 days, only curious if someone else responds. – Horst Walter Dec 15 '22 at 22:31
  • Added some more findings to the original question. Thanks for your help! – Horst Walter Dec 18 '22 at 14:04