Page 1 of 1

Is there any way to switch IMEs in one KeyboardLayout?

Posted: 22 Apr 2024, 12:27
by Giresharu
This code is known to toggle KeyboardLayout:

Code: Select all

 SendMessage(0x50, , kblCode, , imeWinId, , , , 1000)
It can switch the IME between English, Chinese, Japnese, and so on.
But It can't specify which specific IME to use for the switching KeyboardLayout.

In Chinese, there are often many different IMEs that can be used for input.
Such as the character shape IME called Wubi, the phonetic IME called Pinyin, and so on.
(They are different IME software, not different states of an IME software.)

Is there any way to switch them?
The Windows API is a bit large and not easily accessible, does anyone know anything about it and what dll or message to use to switch to a non-default IME of a layout?

Re: Is there any way to switch IMEs in one KeyboardLayout?

Posted: 22 Apr 2024, 14:16
by Seven0528
 I'm currently working on developing a program to address this issue. (I haven't released it yet.)
As you mentioned, simply using WM_INPUTLANGCHANGEREQUEST is not sufficient to switch to a specific input method in Chinese, Japanese, or Korean.
Although there's a method called ITfInputProcessorProfileMgr::ActivateProfile, it's more suitable for selecting input methods within the own process rather than controlling input methods in other processes (even if you combine it with the TF_IPPMF_FORSESSION flag).

You've probably done a lot of searching, but as you know, there's very little information available on this issue.
The only method I can suggest is registering a key sequence for the desired input method in "Text Services and Input Languages" and then using SendInput to trigger it. It's an indirect approach, but it should work fine.

First, press Windows + R and execute the command:

Code: Select all

"rundll32.exe" Shell32.dll,Control_RunDLL input.dll,,{C07337D3-DB2C-4D0B-9A93-B722A6C106E2}{HOTKEYS}
Then, register a key sequence for your desired input method, such as Microsoft Pinyin, and try using SendInput in AHK to trigger it.
20240423_041512.png
(656.75 KiB) Downloaded 70 times

Re: Is there any way to switch IMEs in one KeyboardLayout?

Posted: 23 Apr 2024, 07:30
by garry
it's also possible to run the command with ahk-script
( in german WIN-11 I see only 3 languages (?) )

Code: Select all

#Requires AutoHotkey v2
;Run,%comspec% /k rundll32.exe Shell32.dll`,Control_RunDLL input.dll`,`,{C07337D3-DB2C-4D0B-9A93-B722A6C106E2}{HOTKEYS}  ;- V1
Runwait("rundll32.exe Shell32.dll,Control_RunDLL input.dll,,{C07337D3-DB2C-4D0B-9A93-B722A6C106E2}{HOTKEYS}")
ExitApp()