首页  编辑  

替换一个按键

Tags: /超级猛料/Hardware.硬件相关/键盘和鼠标/   Date Created:

HotKeyId: Integer;

   procedure HotKeyDown(var Msg: Tmessage); message WM_HOTKEY;

procedure TForm1.FormCreate(Sender: TObject);

begin

 HotKeyId := GlobalAddAtom('MyHotKey') - $C000;

 RegisterHotKey(Handle, hotkeyid, 0, 49);

end;

procedure TForm1.HotKeyDown(var Msg: Tmessage);

begin

 if (Msg.LParamHi = 49) then

 begin

   keybd_event(57, MapVirtualKey( 57, 0 ), 0 , 0 );

   keybd_event(57, MapVirtualKey( 57, 0 ), KEYEVENTF_KEYUP , 0 );

 end;

end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);

begin

 UnRegisterHotKey(handle, HotKeyId);

end;