unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
id3: Integer;
procedure WMHotKey(var Msg: TWMHotKey); message WM_HOTKEY;
public
{ Public declarations }
end;
var
x : integer;
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.WMHotKey(var Msg: TWMHotKey);
begin
if Msg.HotKey = id3 then
button1.Click;
end;
procedure TForm1.FormCreate(Sender: TObject);
const
VK_F4 = $73;
begin
x := 0;
id3 := GlobalAddAtom('Hotkey3');
RegisterHotKey(
Handle, id3, 0, VK_F4);
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
UnRegisterHotKey(
Handle, id3);
GlobalDeleteAtom(id3);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if x = 0 then begin
x:= 1;
ShowWindow(FindWindow(nil, 'Program Manager'), SW_SHOW);
end else if x= 1 then begin
x:= 0;
ShowWindow(FindWindow(nil, 'Program Manager'), SW_HIDE);
end;
end;
end.