引言:MSDN中关于Imm的说明太简略了,而且英文的看不太懂。为此我特地编写了一些小程序测试Imm API,终于被我搞清楚了。
WM_INPUTLANGCHANGE
简介:当窗口接收到WM_INPUTLANGCHANGE消息时,表示输入法发生了改变。
声明:#define WM_INPUTLANGCHANGE 0x0051
wParam:该输入法使用的字符集。提示:可以使用TranslateCharsetInfo这个API得到字符集的信息。
lParam:该输入法的HKL(KeyboardLayout——键盘布局,也被称为 Input locale identifier —— 输入区域标识)。
备注:此时可以调用ImmGetDescription取得输入法名,可以调用ImmGetIMEFileName得到该输入法的文件位置……最重要的是使用ImmGetProperty得到输入法属性。
ImmGetProperty
简介:取得输入法的属性(特性)。MSDN: The ImmGetProperty function retrieves the property and capabilities of the IME associated with the specified input locale.
原形:DWORD ImmGetProperty(HKL hKL,
DWORD fdwIndex);
hKL:输入法的HKL。
fdwIndex:返回哪种属性。是这些值:
[ -4]IGP_GETIMEVERSION:输入法接口所使用的版本。MSDN: Retrieves the system version number for which the specified IME was created.
[0x04]IGP_PROPERTY:输入属性。MSDN: Property information.
[0x08]IGP_CONVERSION:组字属性。MSDN: Conversion capabilities.
[0x0C]IGP_SENTENCE:组句属性。MSDN: Sentence mode capabilities.
[0x10]IGP_UI:用户界面(主要是文本旋转特性)。MSDN: User interface capabilities.
[0x14]IGP_SETCOMPSTR:设置组字串的能力。MSDN: Composition string capabilities.
[0x18]IGP_SELECT:切换输入法的继承特性。MSDN: Selection inheritance capabilities.
返回值:该输入法属性。根据fdwIndex所填的常数而返回不同的属性:
IGP_GETIMEVERSION:
[0x0003000A]IMEVER_0310:该输入法基于 Windows 3.1。MSDN: The IME was created for Windows 3.1
[0x00040000]IMEVER_0400:该输入法基于 Windows 9X(不要奇怪,现在WinXP改用TSF了)。MSDN: The IME was created for Windows 95/98/Me.
IGP_PROPERTY:
[0x00010000]IME_PROP_AT_CARET:组字窗口在插入符(caret,文本光标所在位置)附近(如微软拼音、紫光拼音)。MSDN: If set, conversion window is at the caret position. If clear, the window is near caret position.
[0x00020000]IME_PROP_SPECIAL_UI:该输入法有自己的特殊窗口(如微软拼音、紫光拼音),应用程序不能自己绘制输入法窗口。MSDN: If set, IME has a nonstandard user interface. The application should not draw in the IME window.
[0x00040000]IME_PROP_CANDLIST_START_FROM_1:(使用时)候选窗口中的列表是从1开始编号的。MSDN: If set, strings in the candidate list are numbered starting at 1. If clear, strings start at 0.
[0x00080000]IME_PROP_UNICODE:该输入法是支持Unicode的。MSDN: If set, the IME is viewed as a Unicode IME. The system and the IME will communicate through the Unicode IME interface. If clear, IME will use the ANSI interface to communicate with the system.
[0x00100000]IME_PROP_COMPLETE_ON_UNSELECT:当窗口失去焦点时,也将当前输入字符串提交。MSDN: Windows 98/Me, Windows 2000/XP: If set, the IME will complete the composition string when the IME is deactivated. If clear, the IME will cancel the composition string when the IME is deactivated (for example, from a keyboard layout change).
[??????????]IME_PROP_ACCEPT_WIDE_VKEY:输入法发送Unicode字符数据是用SendInput发送VK_PACKET。MSDN: Windows 2000/XP: If set, the IME processes the injected Unicode that came from the SendInput function by using VK_PACKET. If clear, the IME might not process the injected Unicode, and the injected Unicode might be sent to the application directly.
IGP_CONVERSION:
[0x0000]IME_CMODE_ALPHANUMERIC:英文字母和数字输入。
[0x0001]IME_CMODE_NATIVE:本地语言输入。MSDN: Set to 1 if NATIVE mode; 0 if ALPHANUMERIC mode.
[0x0002]IME_CMODE_KATAKANA:[日]片假名。MSDN: Set to 1 if KATAKANA mode; 0 if HIRAGANA mode.
[0x0003]IME_CMODE_LANGUAGE:???。
[0x0008]IME_CMODE_FULLSHAPE:全角/半角。MSDN: Set to 1 if full shape mode; 0 if half shape mode.
[0x0010]IME_CMODE_ROMAN:[日?]罗马?。MSDN: Set to 1 if ROMAN input mode; 0 if not.
[0x0020]IME_CMODE_CHARCODE:直接输入字符内码?MSDN: Set to 1 if character code input mode; 0 if not.
[0x0040]IME_CMODE_HANJACONVERT:[韩]汉字字符模式。MSDN: Set to 1 if HANJA convert mode; 0 if not.
[0x0080]IME_CMODE_SOFTKBD:软键盘。MSDN: Set to 1 if Soft Keyboard mode; 0 if not.
[0x0100]IME_CMODE_NOCONVERSION:不转换。MSDN: Set to 1 to prevent processing of conversions by IME; 0 if not.
[0x0200]IME_CMODE_EUDC:用户自定义字符。MSDN: Set to 1 if EUDC conversion mode; 0 if not.
[0x0400]IME_CMODE_SYMBOL:中文标点。MSDN: Set to 1 if SYMBOL conversion mode; 0 if not.
[0x0800]IME_CMODE_FIXED:???MSDN: Windows 98/Me, Windows 2000/XP: Set to 1 if fixed conversion mode; 0 if not.
IGP_SENTENCE:
[0x0000]IME_SMODE_NONE:没有组句信息。MSDN: No information for sentence.
[0x0001]IME_SMODE_PLAURALCLAUSE:有多个子句信息。MSDN: The IME uses plural clause information to carry out conversion processing.
[0x0002]IME_SMODE_SINGLECONVERT:单字符模式。MSDN: The IME carries out conversion processing in single-character mode.
[0x0004]IME_SMODE_AUTOMATIC:自动模式。MSDN: The IME carries out conversion processing in automatic mode.
[0x0008]IME_SMODE_PHRASEPREDICT:词语联想。MSDN: The IME uses phrase information to predict the next character.
[0x0010]IME_SMODE_CONVERSATION:逐键提示。MSDN: The IME uses conversation mode. This is useful for chat applications.
IGP_UI:
[0x00000001]UI_CAP_2700:支持0度和270度排版(中文竖行排版)。MSDN: Supports text escapement values of 0 or 2700. For more information, see the lfEscapement member of the LOGFONT structure.
[0x00000002]UI_CAP_ROT90:支持所有90度排版。MSDN: Supports text escapement values of 0, 900, 1800, or 2700. For more information, see lfEscapement.
[0x00000004]UI_CAP_ROTANY:支持任意角度排版。MSDN: Supports any text escapement value. For more information, see lfEscapement.
IGP_SETCOMPSTR:
[0x00000001]SCS_CAP_COMPSTR:能够调用ImmSetCompositionString设置组字串。MSDN: Can create the composition string by calling the ImmSetCompositionString function with the SCS_SETSTR value.
[0x00000002]SCS_CAP_MAKEREAD:能够修改输入串。MSDN: Can create the reading string from corresponding composition string when using the ImmSetCompositionString function with SCS_SETSTR and without setting lpRead.
[0x00000004]SCS_CAP_SETRECONVERTSTRING:能够使用SCS_SETRECONVERTSTRING常数。MSDN: This IME can support reconversion. Use ImmSetCompositionString to do reconversion.
IGP_SELECT:
[0x00000001]SELECT_CAP_CONVERSION:能够继承组字属性。MSDN: Inherits conversion mode when a new IME is selected.
[0x00000002]SELECT_CAP_SENTENCE:能够继承组句属性。MSDN: Inherits sentence mode when a new IME is selected.
常见输入法的属性
~~~~~~~~~~~~~~~~
全拼输入法 5.0 版:
hWnd:
000403B6
uMsg:
00000051{WM_INPUTLANGCHANGE
wParam:
00000086
lParam:
E0010804
CharSet:
134
HKL:
E0010804
Desc:
全拼输入法 5.0 版
File:
winpy.ime
IGP_GETIMEVERSION:
00040000(262144)
IGP_PROPERTY:
000C0006(786438)
[Enum]IME Property
00040000: IME_PROP_CANDLIST_START_FROM_1
00080000: IME_PROP_UNICODE
IGP_CONVERSION:
000003A9(937)
[Enum]IME Conversion Mode
00000001: IME_CMODE_NATIVE
00000008: IME_CMODE_FULLSHAPE
00000020: IME_CMODE_CHARCODE
00000080: IME_CMODE_SOFTKBD
00000100: IME_CMODE_NOCONVERSION
00000200: IME_CMODE_EUDC
IGP_SENTENCE:
00000000(0)
[Enum]IME Sentence Mode
IGP_UI:
00010002(65538)
[Enum]IME User Interface
00000002: UI_CAP_ROT90
IGP_SETCOMPSTR:
00000003(3)
[Enum]IME set Composition String
00000001: SCS_CAP_COMPSTR
00000002: SCS_CAP_MAKEREAD
IGP_SELECT:
00000000(0)
[Enum]IME Selection inheritance capabilities
智能ABC输入法 5.0 版:
hWnd:
000403B6
uMsg:
00000051{WM_INPUTLANGCHANGE
wParam:
00000086
lParam:
E0040804
CharSet:
134
HKL:
E0040804
Desc:
智能ABC输入法 5.0 版
File:
winabc.ime
IGP_GETIMEVERSION:
00040000(262144)
IGP_PROPERTY:
00040006(262150)
[Enum]IME Property
00040000: IME_PROP_CANDLIST_START_FROM_1
IGP_CONVERSION:
00000189(393)
[Enum]IME Conversion Mode
00000001: IME_CMODE_NATIVE
00000008: IME_CMODE_FULLSHAPE
00000080: IME_CMODE_SOFTKBD
00000100: IME_CMODE_NOCONVERSION
IGP_SENTENCE:
00000001(1)
[Enum]IME Sentence Mode
00000001: IME_SMODE_PLAURALCLAUSE
IGP_UI:
00010002(65538)
[Enum]IME User Interface
00000002: UI_CAP_ROT90
IGP_SETCOMPSTR:
00000003(3)
[Enum]IME set Composition String
00000001: SCS_CAP_COMPSTR
00000002: SCS_CAP_MAKEREAD
IGP_SELECT:
00000000(0)
[Enum]IME Selection inheritance capabilities
区位输入法 5.0 版:
hWnd:
000403B6
uMsg:
00000051{WM_INPUTLANGCHANGE
wParam:
00000086
lParam:
E0050804
CharSet:
134
HKL:
E0050804
Desc:
区位输入法 5.0 版
File:
wingb.ime
IGP_GETIMEVERSION:
00040000(262144)
IGP_PROPERTY:
000C0006(786438)
[Enum]IME Property
00040000: IME_PROP_CANDLIST_START_FROM_1
00080000: IME_PROP_UNICODE
IGP_CONVERSION:
000001A9(425)
[Enum]IME Conversion Mode
00000001: IME_CMODE_NATIVE
00000008: IME_CMODE_FULLSHAPE
00000020: IME_CMODE_CHARCODE
00000080: IME_CMODE_SOFTKBD
00000100: IME_CMODE_NOCONVERSION
IGP_SENTENCE:
00000000(0)
[Enum]IME Sentence Mode
IGP_UI:
00010002(65538)
[Enum]IME User Interface
00000002: UI_CAP_ROT90
IGP_SETCOMPSTR:
00000003(3)
[Enum]IME set Composition String
00000001: SCS_CAP_COMPSTR
00000002: SCS_CAP_MAKEREAD
IGP_SELECT:
00000000(0)
[Enum]IME Selection inheritance capabilities
王码五笔型输入法 86 版:
hWnd:
000403B6
uMsg:
00000051{WM_INPUTLANGCHANGE
wParam:
00000086
lParam:
E0100804
CharSet:
134
HKL:
E0100804
Desc:
王码五笔型输入法 86 版
File:
WINWB86.IME
IGP_GETIMEVERSION:
00040000(262144)
IGP_PROPERTY:
000C0006(786438)
[Enum]IME Property
00040000: IME_PROP_CANDLIST_START_FROM_1
00080000: IME_PROP_UNICODE
IGP_CONVERSION:
000003A9(937)
[Enum]IME Conversion Mode
00000001: IME_CMODE_NATIVE
00000008: IME_CMODE_FULLSHAPE
00000020: IME_CMODE_CHARCODE
00000080: IME_CMODE_SOFTKBD
00000100: IME_CMODE_NOCONVERSION
00000200: IME_CMODE_EUDC
IGP_SENTENCE:
00000000(0)
[Enum]IME Sentence Mode
IGP_UI:
00010002(65538)
[Enum]IME User Interface
00000002: UI_CAP_ROT90
IGP_SETCOMPSTR:
00000003(3)
[Enum]IME set Composition String
00000001: SCS_CAP_COMPSTR
00000002: SCS_CAP_MAKEREAD
IGP_SELECT:
00000000(0)
[Enum]IME Selection inheritance capabilities
王码五笔型输入法 98 版:
hWnd:
000403B6
uMsg:
00000051{WM_INPUTLANGCHANGE
wParam:
00000086
lParam:
E0110804
CharSet:
134
HKL:
E0110804
Desc:
王码五笔型输入法 98 版
File:
WINWB98.IME
IGP_GETIMEVERSION:
00040000(262144)
IGP_PROPERTY:
000C0006(786438)
[Enum]IME Property
00040000: IME_PROP_CANDLIST_START_FROM_1
00080000: IME_PROP_UNICODE
IGP_CONVERSION:
000003A9(937)
[Enum]IME Conversion Mode
00000001: IME_CMODE_NATIVE
00000008: IME_CMODE_FULLSHAPE
00000020: IME_CMODE_CHARCODE
00000080: IME_CMODE_SOFTKBD
00000100: IME_CMODE_NOCONVERSION
00000200: IME_CMODE_EUDC
IGP_SENTENCE:
00000000(0)
[Enum]IME Sentence Mode
IGP_UI:
00010002(65538)
[Enum]IME User Interface
00000002: UI_CAP_ROT90
IGP_SETCOMPSTR:
00000003(3)
[Enum]IME set Composition String
00000001: SCS_CAP_COMPSTR
00000002: SCS_CAP_MAKEREAD
IGP_SELECT:
00000000(0)
[Enum]IME Selection inheritance capabilities
紫光拼音输入法3.0:
hWnd:
000403B6
uMsg:
00000051{WM_INPUTLANGCHANGE
wParam:
00000086
lParam:
E0200804
CharSet:
134
HKL:
E0200804
Desc:
紫光拼音输入法3.0
File:
UNISPIM.IME
IGP_GETIMEVERSION:
00040000(262144)
IGP_PROPERTY:
00020002(131074)
[Enum]IME Property
00020000: IME_PROP_SPECIAL_UI
IGP_CONVERSION:
00000488(1160)
[Enum]IME Conversion Mode
00000008: IME_CMODE_FULLSHAPE
00000080: IME_CMODE_SOFTKBD
00000400: IME_CMODE_SYMBOL
IGP_SENTENCE:
00000000(0)
[Enum]IME Sentence Mode
IGP_UI:
00010001(65537)
[Enum]IME User Interface
00000001: UI_CAP_2700
IGP_SETCOMPSTR:
00000000(0)
[Enum]IME set Composition String
IGP_SELECT:
00000000(0)
[Enum]IME Selection inheritance capabilities
微软拼音2003:
hWnd:
000403B6
uMsg:
00000051{WM_INPUTLANGCHANGE
wParam:
00000086
lParam:
08040804
CharSet:
134
HKL:
08040804
Desc:
File:
IGP_GETIMEVERSION:
00040000(262144)
IGP_PROPERTY:
000D000A(851978)
[Enum]IME Property
00010000: IME_PROP_AT_CARET
00040000: IME_PROP_CANDLIST_START_FROM_1
00080000: IME_PROP_UNICODE
IGP_CONVERSION:
00000009(9)
[Enum]IME Conversion Mode
00000001: IME_CMODE_NATIVE
00000008: IME_CMODE_FULLSHAPE
IGP_SENTENCE:
00000001(1)
[Enum]IME Sentence Mode
00000001: IME_SMODE_PLAURALCLAUSE
IGP_UI:
00000002(2)
[Enum]IME User Interface
00000002: UI_CAP_ROT90
IGP_SETCOMPSTR:
00000007(7)
[Enum]IME set Composition String
00000001: SCS_CAP_COMPSTR
00000002: SCS_CAP_MAKEREAD
00000004: SCS_CAP_SETRECONVERTSTRING
IGP_SELECT:
00000000(0)
[Enum]IME Selection inheritance capabilities
[台湾]微软注音输入法:
hWnd:
000503AE
uMsg:
00000051{WM_INPUTLANGCHANGE
wParam:
00000088
lParam:
04040404
CharSet:
136
HKL:
04040404
Desc:
File:
IGP_GETIMEVERSION:
00040000(262144)
IGP_PROPERTY:
000D000A(851978)
[Enum]IME Property
00010000: IME_PROP_AT_CARET
00040000: IME_PROP_CANDLIST_START_FROM_1
00080000: IME_PROP_UNICODE
IGP_CONVERSION:
00000009(9)
[Enum]IME Conversion Mode
00000001: IME_CMODE_NATIVE
00000008: IME_CMODE_FULLSHAPE
IGP_SENTENCE:
00000001(1)
[Enum]IME Sentence Mode
00000001: IME_SMODE_PLAURALCLAUSE
IGP_UI:
00000002(2)
[Enum]IME User Interface
00000002: UI_CAP_ROT90
IGP_SETCOMPSTR:
00000007(7)
[Enum]IME set Composition String
00000001: SCS_CAP_COMPSTR
00000002: SCS_CAP_MAKEREAD
00000004: SCS_CAP_SETRECONVERTSTRING
IGP_SELECT:
00000000(0)
[Enum]IME Selection inheritance capabilities
[日语]Microsoft Natural Input 2002:
hWnd:
000503AE
uMsg:
00000051{WM_INPUTLANGCHANGE
wParam:
00000080
lParam:
04110411
CharSet:
128
HKL:
04110411
Desc:
File:
IGP_GETIMEVERSION:
00040000(262144)
IGP_PROPERTY:
001D000A(1900554)
[Enum]IME Property
00010000: IME_PROP_AT_CARET
00040000: IME_PROP_CANDLIST_START_FROM_1
00080000: IME_PROP_UNICODE
00100000: IME_PROP_COMPLETE_ON_UNSELECT
IGP_CONVERSION:
0000000B(11)
[Enum]IME Conversion Mode
00000001: IME_CMODE_NATIVE
00000002: IME_CMODE_KATAKANA
00000003: IME_CMODE_LANGUAGE
00000008: IME_CMODE_FULLSHAPE
IGP_SENTENCE:
00000011(17)
[Enum]IME Sentence Mode
00000001: IME_SMODE_PLAURALCLAUSE
00000010: IME_SMODE_CONVERSATION
IGP_UI:
00000002(2)
[Enum]IME User Interface
00000002: UI_CAP_ROT90
IGP_SETCOMPSTR:
00000007(7)
[Enum]IME set Composition String
00000001: SCS_CAP_COMPSTR
00000002: SCS_CAP_MAKEREAD
00000004: SCS_CAP_SETRECONVERTSTRING
IGP_SELECT:
00000003(3)
[Enum]IME Selection inheritance capabilities
00000001: SELECT_CAP_CONVERSION
00000002: SELECT_CAP_SENTENCE
阿拉伯语:
hWnd:
000503AE
uMsg:
00000051{WM_INPUTLANGCHANGE
wParam:
000000B2
lParam:
F0291401
CharSet:
178
HKL:
F0291401
Desc:
File:
IGP_GETIMEVERSION:
00040000(262144)
IGP_PROPERTY:
00090000(589824)
[Enum]IME Property
00010000: IME_PROP_AT_CARET
00080000: IME_PROP_UNICODE
IGP_CONVERSION:
00000000(0)
[Enum]IME Conversion Mode
IGP_SENTENCE:
00000000(0)
[Enum]IME Sentence Mode
IGP_UI:
00000000(0)
[Enum]IME User Interface
IGP_SETCOMPSTR:
00000000(0)
[Enum]IME set Composition String
IGP_SELECT:
00000000(0)
[Enum]IME Selection inheritance capabilities
法语(法国):
hWnd:
000503AE
uMsg:
00000051{WM_INPUTLANGCHANGE
wParam:
00000000
lParam:
040C040C
CharSet:
0
HKL:
040C040C
Desc:
File:
IGP_GETIMEVERSION:
00040000(262144)
IGP_PROPERTY:
00090000(589824)
[Enum]IME Property
00010000: IME_PROP_AT_CARET
00080000: IME_PROP_UNICODE
IGP_CONVERSION:
00000000(0)
[Enum]IME Conversion Mode
IGP_SENTENCE:
00000000(0)
[Enum]IME Sentence Mode
IGP_UI:
00000000(0)
[Enum]IME User Interface
IGP_SETCOMPSTR:
00000000(0)
[Enum]IME set Composition String
IGP_SELECT:
00000000(0)
[Enum]IME Selection inheritance capabilities
英语(英国):
hWnd:
000503AE
uMsg:
00000051{WM_INPUTLANGCHANGE
wParam:
00000000
lParam:
08090809
CharSet:
0
HKL:
08090809
Desc:
File:
IGP_GETIMEVERSION:
00040000(262144)
IGP_PROPERTY:
00090000(589824)
[Enum]IME Property
00010000: IME_PROP_AT_CARET
00080000: IME_PROP_UNICODE
IGP_CONVERSION:
00000000(0)
[Enum]IME Conversion Mode
IGP_SENTENCE:
00000000(0)
[Enum]IME Sentence Mode
IGP_UI:
00000000(0)
[Enum]IME User Interface
IGP_SETCOMPSTR:
00000000(0)
[Enum]IME set Composition String
IGP_SELECT:
00000000(0)
[Enum]IME Selection inheritance capabilities