Hi,
I am using vb.net framework 3.5. I want to lock input devices like keyboard and mouse from my application. Is their is anyway using sendkeys or any method to lock


Thanks in advance.............

Hi,

You can some explanation about Keyboard hook, here.

Thanks for your reply.
But the link provided by you is not helpful for me.
On button click i am generating a word file at the same time i am editing the word file means add header ,footer, page size using the sendkeys at that time i want to stop user to enter any key from keyboard or mouse action. After process completed it will activate again.

Here is code that i am trying but its not working..

Private Declare Function BlockInput Lib "user32" (ByVal fBlock As Long) As Long

Public Shared Sub DisableInput(ByVal makeDisabled As Boolean)
Dim n As Boolean = BlockInput(makeDisabled)
End Sub

Member Avatar for Unhnd_Exception

Try this. It works on my end.

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


dim blocked as boolean = BlockInput(True)

Hi , thanks for reply
i am used this code but nothing work.
is it correct way to write code
in class i am writing

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

and in button click the following code write

dim blocked as boolean = BlockInput(True)

but its not working still the keyboard and mouse are not blocked
please help me.....

Member Avatar for Unhnd_Exception

I can't get it not to work.

Maybe show some of the code your using.

Maybe just disable the form while your doing your processing. It seems a little strange you need to disable keyboard and mouse clicks over the entire operating system to make a word file.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.