datawindow自动切换中英文输入法.txt

来自「PB常用技巧 PB常用技巧 PB常用技巧」· 文本 代码 · 共 50 行

TXT
50
字号
datawindow自动切换中英文输入法
//4个apihansu
function boolean ImmSimulateHotKey (ULong hWnd, ULong dwHotKeyID) library "IMM32.dll"
function boolean ImmIsIME(uLong hklKeyboardLayout) library "IMM32.DLL" 



//取得当前键盘布局
function ulong GetKeyboardLayout(ulong dwLayout) LIBRARY "user32.dll"
//激活当前键盘布局
FUNCTION ulong ActivateKeyboardLayout(ulong HKL,ulong flags) LIBRARY "user32.dll"

//2个全局变量
//自动切换输入法
ulong hklCurrent //键盘布局
ulong hwnd   //窗口句柄
//////////////////////////////////////

//2个全局函数
//参数 ulong hwnd 

//切换到英文输入法:
hklCurrent = GetKeyboardLayout(0)//系统默认输入法
if ImmIsIME(hklCurrent) then
ImmSimulateHotKey(hwnd,112)
ActivateKeyboardLayout(0,1)
end if

//参数 ulong hwnd 

//切换到中文输入法:
hklCurrent = GetKeyboardLayout(0) //系统默认输入法
if not ImmIsIME(hklCurrent) then
ImmSimulateHotKey(hwnd,112)
ActivateKeyboardLayout(0,1)
end if

//引用datawindow itemfocuschanged event


hwnd = Handle(parent)
choose case dwo.name
case 'f_jh','c_xsrq'
  gf_english(hwnd)
case else
  gf_chinese(hwnd)
end choose


⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?