How to automatically control the English input method in the program?

zhaozj2021-02-16  47

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.

转载请注明原文地址:https://www.9cbs.com/read-26075.html

New Post(0)