- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
// используемые переменные
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;