skymag
asked on
Intercept Keyboard Shortcuts
I would like to capture a shortcut pressed even if the Delphi Form doesn't have focus. I am using Delphi 4.
..and again hooks. I can't hear it anymore.
ASKER
Hehe! What does your comment mean?
:-)) Writing system hooks became so popular recently that I fear too many programs will install those hooks to get at least near system wide control.
Unfortunately, in your case you cannot redirect a hotkey which is already registered with the system other than installing a system wide hook.
That's the whole story :-)
Ciao, Mike
Unfortunately, in your case you cannot redirect a hotkey which is already registered with the system other than installing a system wide hook.
That's the whole story :-)
Ciao, Mike
ASKER
Mmmm where can I get a system hook and install it?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Also you can download:
http://delphi.icm.edu.pl/ftp/d30free/hotkeymn.zip
http://delphi.icm.edu.pl/ftp/d30free/hotkeymn.zip
Hi Skymaq:
You neednt use hook,i give you a simple example used Registerhotkey.it can work wonderful.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
procedure OnHotKey(var Message :TWMHotKey); Message WM_HotKey;
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.OnHotKey(var Message :TWMHotKey);
begin
showmessage('you have pressed ctrl+F10');
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
RegisterHotKey(Handle,10,M OD_CONTROL ,VK_F10);
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
UnregisterHotKey(Handle,10 );
end;
end.
it registered Ctrl+f10.
menxin
You neednt use hook,i give you a simple example used Registerhotkey.it can work wonderful.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
procedure OnHotKey(var Message :TWMHotKey); Message WM_HotKey;
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.OnHotKey(var Message :TWMHotKey);
begin
showmessage('you have pressed ctrl+F10');
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
RegisterHotKey(Handle,10,M
end;
procedure TForm1.FormDestroy(Sender:
begin
UnregisterHotKey(Handle,10
end;
end.
it registered Ctrl+f10.
menxin