用VB在程式中新增切換中文輸入法的功能

2021-03-31 08:57:00 字數 1425 閱讀 1425

思路:

先用getkeyboardlayoutlist 函式來取得所有輸入法,然後逐個用immisime判斷是否是中文輸入法,如果是的話在用immgetdescription得到輸入法的名稱,最後選定你需要的輸入法用activatekeyboardlayout啟用它.  

原始碼: 

public declare function activatekeyboardlayout lib "user32" (byval hkl as long, byval flags as long) as long

public declare function getkeyboardlayoutlist lib "user32" (byval nbuff as long, lplist as long) as long

public declare function getkeyboardlayout lib "user32" (byval dwlayout as long) as long

public declare function immgetdescription lib "imm32.dll" alias "immgetdescriptiona" (byval hkl as long,

_byval lpsz as string, byval ubuflen as long) as long

public declare function immisime lib "imm32.dll" (byval hkl as long) as long

public hcurkbdlayout as long

public sub loadsrfz()

dim buff as string

buff = string(255, 0)

dim noofkbdlayout as long

dim bufflen as long

dim retstr as string

hcurkbdlayout = getkeyboardlayout(0)′取得目前的輸入法

noofkbdlayout = getkeyboardlayoutlist(25, hkb(0))

for i = 1 to noofkbdlayout

if immisime(hkb(i - 1)) = 1 then

bufflen = 255

retcount = immgetdescription(hkb(i - 1), buff, bufflen)

retstr = left(buff, retcount)

if left(retstr, len("智慧型abc")) = "智慧型abc" then

activatekeyboardlayout hkb(i - 1), 0

exit sub

end if

end if

next

end sub

在Excel中為中文新增拼音

excel 2000 2002 2003中不僅沒有提供 拼音指南 這一工具,而且當希望在同一單元格中同時顯示拼音和中文字元時,只能先輸入拼音,然後按下alt enter鍵接著輸入中文.1 啟用拼音資訊的顯示模式 其實,我們可以利用excel 2000 2002 2003內建的 拼音指南 功能來達到這...

在Debian中新增Fcitx輸入法

在debian中預設安裝的輸入法為chinput,但由於該輸入法並未提供五筆,所以將其換成fcitx輸入法。其步驟如下 首先是解除安裝chinput,使用命令apt get remove purge chinput 安裝fcitx輸入法,使用命令apt get u install fcitx 建立 ...

用C 程式在excel表中新增批註時的注意事項

用c 寫了乙個操作excel表的程式,其中的一項功能是在單元格中新增批註。除錯過程中偶爾檢視windows任務管理器,發現有許多excel.exe程序。經分析是新增批註後,應用程式結束執行時未能關閉excel.exe程序。新增批註的語句原來是 write range.addcomment new v...