如果是全局的hotkey,可以:
用RegisterHotKey, 下面的热键在全局(即使当前激活的是其他进程)有效
procedure TForm1.FormCreate(Sender: TObject);
begin
RegisterHotKey(Handle,123,MOD_CONTROL,integer('A'));
//123是自己定义的id ,热键是 ctrl+A
end;
Tform1 类定义加上一行:procedure ON_WM_HOTKEY(var m:TMessage);message WM_HOTKEY;
procedure TForm1.ON_WM_HOTKEY(var m: TMessage);
begin
if(m.WParam=123)then
//如果id是123
windows.Beep(1000,1000);
end;