Réponse acceptée !
Salut,
oui c'est parfaitement possible ... sans Hook et sans Timer
Type
TForm1 =
Class(TForm)
Procedure FormCreate(Sender: TObject);
Procedure FormDestroy(Sender: TObject);
Private
{ Private declarations } HotKeyID1 : Integer;
Procedure WMHotKey(
Var Msg: TWMHotKey);
Message WM_HOTKEY;
Procedure RegisterHotKeys;
Procedure UnRegisterHotKeys;
Public
{ Public declarations } End;
Var
Form1: TForm1;
Implementation
{$R *.dfm}Procedure TForm1.WMHotKey(
Var Msg: TWMHotKey);
Begin
If MSG.HotKey = HotKeyID1
Then
MessageBox(Handle ,
'Touche F1 pressée',
'Information', MB_ICONINFORMATION
Or MB_SETFOREGROUND);
End;
Procedure TForm1.RegisterHotKeys;
Begin
HotKeyID1 := GlobalAddAtom(
'Hotkey1');
RegisterHotKey(Handle, HotKeyID1,
0, VK_F1);
End;
Procedure TForm1.UnRegisterHotKeys;
Begin
UnRegisterHotKey(Handle, HotKeyID1);
End;
Procedure TForm1.FormCreate(Sender: TObject);
Begin
RegisterHotKeys;
End;
Procedure TForm1.FormDestroy(Sender: TObject);
Begin
UnRegisterHotKeys;
End;
End.
@+
Cirec