All pastes #17580 Raw Edit

Anonymous

public text v1 · immutable
#17580 ·published 2005-07-12 22:49 UTC
rendered paste body
library hotlock;

uses
  windows,
  Messages;

type
  TDummy = class
  private
    id1: Integer;
    procedure WMHotKey(var Msg: TWMHotKey); message WM_HOTKEY;
  public
    procedure Keybind1;
    procedure EnableHotKey;
    procedure DisableHotKey;
  end;

var
  Dummy: TDummy;

procedure TDummy.WMHotKey(var Msg: TWMHotKey);
begin
  if Msg.HotKey = id1 then
    Dummy.Keybind1;
end;

procedure TDummy.Keybind1;
begin
MessageBox(0, 'KEYBIND1 was captured', 'SUCCESS!', 0);
dummy.DisableHotKey;
//dummy.Free;
end;

procedure TDummy.EnableHotKey;
begin
//Globally trap the Windows system key "PrintScreen"
id1 := GlobalAddAtom('Hotkey1');
RegisterHotKey(0, id1, 0, VK_SNAPSHOT);
end;

procedure TDummy.DisableHotKey;
begin
//Unregister the Hotkey
UnRegisterHotKey(0, id1);
GlobalDeleteAtom(id1);
end;

begin
Dummy := Tdummy.Create;
Dummy.EnableHotKey;
end.