Declare API function:
Function Boolean Immsimulatehotkey (Ulong Hwnd, Ulong DwhotKeyid) library "imm32.dll"
Function Ulong getKeyboardLayout (Ulong DwLayout) library "user32.dll"
Function Boolean Immisime (Ulong HKLKeyboardLayout) library "imm32.dll"
Define variables:
Constant Int IME_THOTKEY_IME_NONIME_TOGGLE = 112
Ulong hklcurrent
Ulong HND
Switch to English input method:
HKLCurrent = getKeyboardLayout (0)
IF immisime (hklcurrent) THEN
HND = Handle (PARENT)
Immsimulatehotkey (HND, IME_THOTKEY_IME_NONIME_TOGGLE)
END IF
Switch to Chinese input method:
HKLCurrent = getKeyboardLayout (0)
IF not immisime (hklcurrent) THEN
HND = Handle (PARENT)
Immsimulatehotkey (HND, IME_THOTKEY_IME_NONIME_TOGGLE)
END IF
You can trigger two different scripts to achieve dynamic switching methods for dynamic switches.