在宏完成之前,阻止计算机上的任何单击事件



这是一种防止在计算机上单击鼠标直到 Access VBA 上的宏结束的方法吗?宏需要一个特定的应用程序才能成为焦点,所以我不想让用户在宏运行时转到其他地方。

您可以使用WinApiBlockInput函数来阻止任何输入,包括任务切换或其他任何内容。

Declare PtrSafe Function BlockInput Lib "User32.dll" (ByVal fBlockIt As Boolean) As Boolean
Private Sub DoStuff()
On Error GoTo ErrHandler
BlockInput True
'Do stuff here
BlockInput False
Exit Sub
ErrHandler:
BlockInput False 'Important! During message boxes, error handling, etc. input will still be blocked
'Handle error here
Exit Sub

请注意,BlockInput是绝对的。你根本不能做任何事情,除了Ctrl+Alt+Delete摆脱它。

在某些安全配置中,可以禁用BlockInput,但通常,它无需管理员权限或类似权限即可使用。

这是不可能的。您可以随时转到另一个窗口或任务栏。

Yo,

我无法在 VBA 中完成,但有一些程序可以做到这一点。 因此,您可能需要找到VBA-ProgramYouChoose-组合的解决方法。

这是链接:

https://www.raymond.cc/blog/how-to-restrict-or-disable-keyboard-mouse-and-even-power-button/

这些是他们讨论的程序:

钥匙

冻结
幼儿陷阱
幼儿钥匙儿童钥匙
锁键盘锁儿童锁

捕食者

您必须测试这些,因为您只想禁用鼠标,我会选择儿童钥匙锁。

相关内容

最新更新