Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to set hotkey? - delphi

Status
Not open for further replies.

andrejchy

Programmer
Oct 14, 2006
1
SI
Can someone give me some directins...
I would like to make my program react on some key combinations also when the program is not active.
tnx
 
You need to install some keyhook, examples I saw on torry.net, needs a little searching though.

HTH
TonHu
 
try this. Hope it helps !

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;

type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
Procedure WMHotKey(Var msg: TWMHotkey);
message WM_HOTKEY;
public
{ Public declarations }
end;

var
Form1: TForm1;
handle : HWND;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
//RegisterHotKey(handle,1,mod_control+mod_alt+mod_shift,ord('K'));
RegisterHotKey(handle,1,mod_control,ord('K')); //react on CTRL+K
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
UnRegisterHotKey(handle,1);
end;

procedure TForm1.WMHotKey(Var msg: TWMHotkey);
begin
SetForegroundWindow(Application.Handle);
Showmessage('Hello !');
end;

end.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top