// используемые переменные
var
Dummy: integer = 0;
OldKbHook: HHook = 0;
implementation
function KbHook(code: Integer; wparam: Word; lparam: LongInt): LongInt; stdcall;
begin
if code < 0 then
Result := CallNextHookEx(oldKbHook, code, wparam, lparam)
else
Result := 1;
end;
// включение клавы
procedure TForm1.KeyBoardOn(Sender: TObject);
begin
if OldKbHook <> 0 then
begin
UnHookWindowshookEx(OldKbHook);
OldKbHook := 0;
end;
SystemParametersInfo(SPI_SETFASTTASKSWITCH, 0, 0, 0);
SystemParametersInfo(SPI_SCREENSAVERRUNNING, 0, 0, 0);
end;
// выключение клавы
procedure TForm1.KeyBoardOff(Sender: TObject);
begin
SystemParametersInfo(SPI_SETFASTTASKSWITCH, 1, @Dummy, 0);
SystemParametersInfo(SPI_SCREENSAVERRUNNING, 1, @Dummy, 0);
OldKbHook := SetWindowsHookEx(WH_KEYBOARD, @KbHook, HInstance, 0);
end;
|