首页  编辑  

设置输入法的热键

Tags: /超级猛料/IME.Charset.输入法和中文处理/   Date Created:

用SystemParametersInfo应该可以。

The SystemParametersInfo function queries or sets systemwide

parameters. This function can also update the user profile

while setting a parameter.

BOOL SystemParametersInfo(

   UINT uiAction,        // system parameter to query or set

   UINT uiParam,        // depends on action to be taken

   PVOID pvParam,        // depends on action to be taken

   UINT fWinIni        // user profile update flag

  );

其中 uiAction有个SPI_SETLANGTOGGLE参数:

SPI_SETLANGTOGGLE:  Sets the hot key set for switching between input

                   languages. The uiParam and pvParam parameters are

                   not used. The value sets the shortcut keys in the

                   keyboard property sheets by reading the registry

                   again. The registry must be set before this flag

                   is used. the path in the registry is

                   \HKEY_CURRENT_USER\keyboard layout\toggle. Valid

                   values are "1" = ALT+SHIFT, "2" = CTRL+SHIFT, and

                   "3" = none.

>>各位能给个简单的例子吗如设置ALT+3为拼音输入法?

uses ..., Registry;

procedure TForm1.Button1Click(Sender: TObject);

var

 myReg: TRegistry;

const

 buf1: array[0..3] of Byte = ($01, $c0, $00, $00);

 buf2: array[0..3] of Byte = ($04, $08, $01, $e0);

 buf3: array[0..3] of Byte = ($33, $00, $00, $00);

begin

 myReg := TRegistry.Create;

 try

   myReg.RootKey := HKEY_CURRENT_USER;

   if myReg.OpenKey('Control Panel\Input Method\Hot Keys\00000100', True) then

   begin

     myReg.WriteBinaryData('Key Modifiers', buf1, 4);

     myReg.WriteBinaryData('Target IME', buf2, 4);

     myReg.WriteBinaryData('Virtual Key', buf3, 4);

   end;

   myReg.CloseKey;

 finally

   myReg.Free;

 end;

end;

重新启动计算机,Alt+3即为全拼输入法的热键。