Link to home
Start Free TrialLog in
Avatar of skymag
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.
Avatar of Lischke
Lischke

..and again hooks. I can't hear it anymore.
Avatar of skymag

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
Avatar of skymag

ASKER

Mmmm where can I get a system hook and install it?
ASKER CERTIFIED SOLUTION
Avatar of ronit051397
ronit051397

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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,MOD_CONTROL,VK_F10);
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  UnregisterHotKey(Handle,10);
end;


end.

it registered Ctrl+f10.

menxin