Delphi全域性熱鍵註冊
阿新 • • 發佈:2019-01-27
private { Private declarations } Aatom: ATOM; procedure hotkey(var msg: TMessage); message WM_HOTKEY; procedure TForm1.FormCreate(Sender: TObject); begin if FindAtom('ZWXhotKey') = 0 then begin Aatom := GlobalAddAtom('ZWXhotKey'); end; if RegisterHotKey(Handle, Aatom, MOD_ALT, $41) then begin MessageBox(Handle, '按alt+a', '提示', MB_OK); end; end; procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction); begin UnregisterHotKey(Handle, Aatom); GlobalDeleteAtom(Aatom); end; procedure TForm1.hotkey(var msg: TMessage); begin if (msg.LParamHi = $41) and (msg.LParamLo = MOD_ALT) then begin showmessage('Ctrl+A'); end; end;