Board index » delphi » Partly block keyboard mouse events

Partly block keyboard mouse events

Hi,

Is there a way to block keyboard and mouse input only from the user ?
I want to generate keyb_event and mouse_event calls, these I want to be
still enabled,
but when a user generates a mouse or keyboard event I don't want the PC to
respond (system wide).

Is there a call to the keyboard and mouse driver to do this ?

Greetings,
0BIT

 

Re:Partly block keyboard mouse events


Quote
"0BIT" <some...@123.com> wrote in message

news:hgsya.100474$me2.12064233@amsnews02.chello.com...

Quote
> Hi,

> Is there a way to block keyboard and mouse input only from the user ?
> I want to generate keyb_event and mouse_event calls, these I want to be
> still enabled,
> but when a user generates a mouse or keyboard event I don't want the PC to
> respond (system wide).

> Is there a call to the keyboard and mouse driver to do this ?

blockinput(true); //turns off mouse and keyboard
blockinput(false); //turns on mouse and keyboard

Pressing Control Alt Delete will turn the keyboard and mouse back on.

function FunctionDetect(LibName, FuncName: string; var LibPointer: Pointer):
boolean;
var LibHandle: tHandle;
begin
  Result := false;
  LibPointer := nil;
  if LoadLibrary(PChar(LibName)) = 0 then exit;
  LibHandle := GetModuleHandle(PChar(LibName));
  if LibHandle <> 0 then
  begin
    LibPointer := GetProcAddress(LibHandle, PChar(FuncName));
    if LibPointer <> nil then Result := true;
  end;
end;

procedure blockinput(const blocked: boolean);
var xBlockInput: function(Block: BOOL): BOOL; stdcall;
begin
  if FunctionDetect('USER32.DLL', 'BlockInput', @xBlockInput) then
    xBlockInput(blocked);
end;

Cheers,
Nicholas Sherlock

Other Threads