PB中中英文的切换

来源:互联网 发布:录音软件手机版 编辑:程序博客网 时间:2024/06/07 04:48

在 9x系统中:

函数声明:
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"

脚本如下:
constant int IME_THotKey_IME_NonIME_Toggle=112
ulong hklCurrent
ulong hnd

//切换到英文输入法
hklCurrent=GetKeyboardLayout(0)
if ImmIsIME(hklCurrent) then
hnd=Handle(parent)
ImmSimulateHotKey(hnd,IME_THotKey_IME_NonIME_Toggle)
end if

//切换到中文输入法
hklCurrent=GetKeyboardLayout(0)
if not ImmIsIME(hklCurrent) then
hnd=Handle(parent)
ImmSimulateHotKey(hnd,IME_THotKey_IME_NonIME_Toggle)
end if

在2k 和xp中

constant int IME_THotKey_IME_NonIME_Toggle=112

变成:

constant int IME_THotKey_IME_NonIME_Toggle=16