开发者

Lock mouse and keybord in VB.NET

开发者 https://www.devze.com 2023-02-21 17:15 出处:网络
Is there a way to block the mouse/keybord from .NET but System-wide? I tried with <System.Runtime.InteropServices.DllImport(\"User32.dll\")> _

Is there a way to block the mouse/keybord from .NET but System-wide? I tried with

<System.Runtime.InteropServices.DllImport("User32.dll")> _
Public Shared Function BlockInput(ByVal block As Boolean) As Boolean
End Function

but it did not work.

I would like to avoid solutions like loading 开发者_Python百科a driver, but I am open to that if needs be.

Edit: It did not work, because I stupidly did NOT run it with Administrator priviledges. So, the real question is how to block Ctrl-Alt-Del. Sorry for the mix-up and thank you for your answers!

Thank you,

John


For fine-grained control you could set up global hooks for the mouse and keyboard - WH_KEYBOARD_LL and WH_MOUSE_LL - then suppress the keystrokes and mouse movements by returning (IntPtr)1 from the hook instead of calling CallNextHookEx

0

精彩评论

暂无评论...
验证码 换一张
取 消