可以的,只是很多已被系统占用了。
[Delphi] 纯文本查看 复制代码 unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs;
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
procedure OnHotKey(var msg: TMessage); message WM_HOTKEY;
public
{ Public declarations }
end;
var
Form1: TForm1;
HotKeyId: Integer;
keyCode : Integer;
implementation
{$R *.dfm}
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
UnRegisterHotKey(handle, HotKeyId);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
keyCode := 89; //65=a
HotKeyId:= GlobalAddAtom('Hotkeyid') - $C000;
//RegisterHotKey(Handle, hotkeyid, MOD_CONTROL+MOD_ALT+MOD_WIN, keyCode);
RegisterHotKey(Handle, hotkeyid, MOD_WIN, keyCode);
end;
procedure TForm1.OnHotKey(var msg: TMessage);
var szMsg: string;
begin
//if(msg.LParamLo = MOD_CONTROL+MOD_ALT+MOD_WIN) and (msg.LParamHi = keyCode) then
if(msg.LParamLo = MOD_WIN) and (msg.LParamHi = keyCode) then
begin
//szMsg:= '你按下了Ctrl + alt + WIN + a';
szMsg:= '你按下了 WIN + y';
ShowMessage(szMsg);
end
end;
end. |