Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I block keyboard and mouse input?

Status
Not open for further replies.

wolfie78uk

Programmer
Jul 3, 2002
35
GB
I need to block all mouse and keyboard input whilst my application is interacting with another application. The blocking of input has to be global (i.e the blocking is not specific to my application).

There is a library function for C++ called "BlockInput" which would do the trick, but unfortunately I'm using VB and there doesn't appear to be anything similar in the API viewer.

Can anybody help?

Thanks in advance.
 
Private Declare Function BlockInput Lib "user32" (ByVal fBlock As Boolean) As Boolean

Then call it:
BlockInput True

You could try something like this to test it:

Private Sub Command1_Click()
BlockInput True
For i = 1 To 10000
DoEvents
lblCaption = CStr(i)
Next i
BlockInput False
MsgBox "Test Complete!", vbInformation
End Sub
Swi
 
It doesn't work. I just get "Sub or Function not defined".
 
Did you put the Declare bit 'Private Declare Function BlockInput Lib "user32" (ByVal fBlock As Boolean) As Boolean' in your Form declarations section?
You may also need to Dim i in the Command1_Click event Let me know if this helps
________________________________________________________________
If you are worried about how to post, please check out FAQ222-2244 first

'There are 10 kinds of people in the world: those who understand binary, and those who don't.'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top