Mega Code Archive

 
Categories / Delphi / Hardware
 

Disable Keyboard and Mouse

Title: Disable Keyboard and Mouse Question: How to disable mouse and keyboard for n seconds Answer: // This Function detect is Function exists in Library (dll) function FuncAvail (VLibraryname, VFunctionname: string; var VPointer: pointer): boolean; var Vlib: tHandle; begin Result := false; VPointer := NIL; if LoadLibrary(PChar(VLibraryname)) = 0 then exit; VPointer := GetModuleHandle(PChar(VLibraryname)); if Vlib 0 then begin VPointer := GetProcAddress(Vlib, PChar(VFunctionname)); if VPointer NIL then Result := true; end; end; // Source code in Button1 on Form1 - procedure TForm1.Button1Click(Sender: TObject); var xBlockInput : function(Block: BOOL): BOOL; stdcall; begin if FuncAvail('USER32.DLL', 'BlockInput', @xBlockInput) then begin xBlockInput(true); Sleep(15000); // 15 secounds xBlockInput(false); end; end;