完全阻止键盘输入

发布于 2025-01-01 06:56:36 字数 922 浏览 3 评论 0原文

有什么办法可以完全阻止键盘输入吗?这也应该阻止像 WIN+E 这样的组合键。

我找到了这段代码,有没有办法将其更改为仅阻止键盘输入(鼠标需要工作)

    procedure TForm1.Button1Click(Sender: TObject) ;

   function FuncAvail(dllName, funcName: string; var p: pointer): boolean;
   var
     lib: THandle;
   begin
     result := false;
     p := nil;
     if LoadLibrary(PChar(dllName)) = 0 then exit;
     lib := GetModuleHandle(PChar(dllName)) ;
     if lib <> 0 then
     begin
      p := GetProcAddress(lib, PChar(funcName)) ;
      if p <> nil then Result := true;
     end;
   end;

   var
     BlockInput : function(Block: BOOL): BOOL; stdcall;

   begin
    if FuncAvail('USER32.DLL', 'BlockInput', @BlockInput) then
    begin
     ShowMessage('Your Mouse and Keyboard will be blocked for 5 seconds!') ;
     BlockInput(true) ;
     Sleep(5000) ;
     BlockInput(false) ;
    end;
   end;

 end.

这段代码也可以与 WIN 键等一起使用吗?

谢谢!

Is there any way to block the Keyboard input completely ? This should also block key combos like WIN+E.

I found this Code, is there anyway to change it to block only keyboard input (Mouse needs to work)

    procedure TForm1.Button1Click(Sender: TObject) ;

   function FuncAvail(dllName, funcName: string; var p: pointer): boolean;
   var
     lib: THandle;
   begin
     result := false;
     p := nil;
     if LoadLibrary(PChar(dllName)) = 0 then exit;
     lib := GetModuleHandle(PChar(dllName)) ;
     if lib <> 0 then
     begin
      p := GetProcAddress(lib, PChar(funcName)) ;
      if p <> nil then Result := true;
     end;
   end;

   var
     BlockInput : function(Block: BOOL): BOOL; stdcall;

   begin
    if FuncAvail('USER32.DLL', 'BlockInput', @BlockInput) then
    begin
     ShowMessage('Your Mouse and Keyboard will be blocked for 5 seconds!') ;
     BlockInput(true) ;
     Sleep(5000) ;
     BlockInput(false) ;
    end;
   end;

 end.

Would this code also work with WIN keys etc ?

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

时光倒影 2025-01-08 06:56:36

你想得太难了。

设置可以通过鼠标而非键盘控制的信息亭的正确方法是不连接键盘。(这也使得不道德的信息亭用户无法窃取您的键盘.)

这也意味着,如果您需要执行管理任务,您可以连接键盘(或遥控器),一切都会正常工作。

You're thinking way too hard.

The appropriate way to set up a kiosk that can be controlled by the mouse and not the keyboard is to not have a keyboard attached. (This also makes it impossible for an unscrupulous kiosk-user to steal your keyboard.)

This also means that, if you need to perform administrative tasks, you can attach a keyboard (or remote in) and everything will work fine.

泪之魂 2025-01-08 06:56:36

如果由于某种原因删除键盘不是一个可行的选择,则有一种不受支持的软件方法:从其中删除 UpperFilters 值

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E96B-E325-11CE-BFC1-08002BE10318}

这会禁用所有正常键盘设备的输入,但远程桌面虚拟键盘仍然可以工作,因此您可能需要首先确保远程桌面已配置并正常工作。

作为参考,如果您想反转该过程,UpperFilters 通常是包含单个字符串“kbdclass”(不带引号)的 REG_MULTI_SZ。

If for some reason removing the keyboard is not a feasible option, there is an unsupported way of doing this in software: remove the UpperFilters value from

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E96B-E325-11CE-BFC1-08002BE10318}

This disables input from all normal keyboard devices, but the Remote Desktop virtual keyboard will still work, so you may want to ensure that Remote Desktop is configured and working first.

For your reference, should you want to reverse the process, UpperFilters is normally a REG_MULTI_SZ containing a single string "kbdclass" (without the quote marks).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文