hisense
6 years agoOccasional Contributor
How to block keyboard when script running?
How to block keyboard when script running?
- 6 years ago
Hi,
Does this help?
(Note: ages old DelphiScript code that might not work in modern TestComplete and/or Windows and I think that you definitely must consider bitness as described here: https://support.smartbear.com/testcomplete/docs/testing-with/advanced/using-external-functions/calling-from-dll/specifics-of-32-and-64-bit-dlls.html)
//-------------------------------------------------------------------------------// Blocks keyboard and mouse input events from reaching applications.
// Function's effect can be cancelled by pressing Ctrl-Alt-Del
procedure StopKeyMouse;var Def_DLL;
var Def_Proc;
var Lib;begin
Def_DLL := DLL.DefineDLL('USER32');
Def_Proc := Def_DLL.DefineProc('BlockInput', vt_b1, vt_b1);
Lib := DLL.Load('USER32.DLL', 'USER32');
Lib.BlockInput(true);
end;
//-------------------------------------------------------------------------------// Unblocks keyboard and mouse input events from reaching applications.
procedure ResumeKeyMouse;var Def_DLL;
var Def_Proc;
var Lib;begin
Def_DLL := DLL.DefineDLL('USER32');
Def_Proc := Def_DLL.DefineProc('BlockInput', vt_b1, vt_b1);
Lib := DLL.Load('USER32.DLL', 'USER32');
Lib.BlockInput(false);
end;
//-------------------------------------------------------------------------------