• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 577
  • Last Modified:

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.
0
skymag
Asked:
skymag
  • 2
  • 2
  • 2
  • +1
1 Solution
 
LischkeCommented:
..and again hooks. I can't hear it anymore.
0
 
skymagAuthor Commented:
Hehe! What does your comment mean?
0
 
LischkeCommented:
:-)) 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
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
skymagAuthor Commented:
Mmmm where can I get a system hook and install it?
0
 
ronit051397Commented:
0
 
men xinCEOCommented:
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
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now