Hello,
I type in many different languages and I currently have a problem with the auto-correct function in word. I use the colemak layout when typing in a language which uses the Latin alphabet (seen by windows, and consequently by word as "English") and a custom "Russian phonetic colemak" when typing in Russian.
My current problem is the fact that when I switch from Russian to colemak, the spell checker automatically switch to "English" even if before that the document language was Swedish or Italian.
I have already found a solution: cloning my Colemak each time with a different layout native attribute (I use kbdedit for that). It works, the problem being, to switch languages, I often have to press 10 times in a row win + space, which is a bit annoying to say the least.
I tried this script and it seems it would solve my problem by allowing me to use a different shortcut for each languages.
My problem is, if I use for example
Code: Select all
^1::SetDefaultKeyboard(0x0419) ; Russian
to switch to Russian, it automatically add the standard Russian keyboard and switch to it (same for the other languages.
My customs keyboard have different KLID values (Standard Russian KLID = 00000419, my custom Russian KLID b0040419)
Based on the information found in this thread
https://autohotkey.com/board/topic/18343-dllcall-loadkeyboardlayout-problem/ I tried to modify the script in the following way:
Code: Select all
SetDefaultKeyboard(LocaleID){
Static SPI_SETDEFAULTINPUTLANG := 0x005A, SPIF_SENDWININICHANGE := 2
Lan := DllCall("LoadKeyboardLayout", "Str", LocaleID, "UINT", 1)
VarSetCapacity(binaryLocaleID, 4, 0)
NumPut(LocaleID, binaryLocaleID)
DllCall("SystemParametersInfo", "UInt", SPI_SETDEFAULTINPUTLANG, "UInt", 0, "UPtr", &binaryLocaleID, "UInt", SPIF_SENDWININICHANGE)
WinGet, windows, List
Loop % windows {
PostMessage 0x50, 0, % Lan, , % "ahk_id " windows%A_Index%
}
}
^1::SetDefaultKeyboard(a0000409) ; English
^2::SetDefaultKeyboard(b0030419) ; Russian
But it doesn't work as intended and when pressing ctr+1 it still load the default US keyboard (which is not active on my system).
Any idea what I do wrong?
Thank you in advance for any help
Lol, a few minutes after posting this message, I found what I had done wrong and managed to correct it. I do not remove my post, just in case someone would have a similar need.
The solution was
Code: Select all
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
#SingleInstance, Force;
SetDefaultKeyboard(LocaleID){
Static SPI_SETDEFAULTINPUTLANG := 0x005A, SPIF_SENDWININICHANGE := 2
Lan := DllCall("LoadKeyboardLayout", "Str", Format("{:08x}", LocaleID), "UINT", 1)
VarSetCapacity(binaryLocaleID, 4, 0)
NumPut(LocaleID, binaryLocaleID)
DllCall("SystemParametersInfo", "UInt", SPI_SETDEFAULTINPUTLANG, "UInt", 0, "UPtr", &binaryLocaleID, "UInt", SPIF_SENDWININICHANGE)
WinGet, windows, List
Loop % windows {
PostMessage 0x50, 0, % Lan, , % "ahk_id " windows%A_Index%
}
}
^1::SetDefaultKeyboard(0xa0000409) ; English
^2::SetDefaultKeyboard(0xb0030419) ; Russian
A big thank you for this script which will go a long way in helping me preserving what remains of my sanity