wish that anyone can help me in this, im working on administration project, and i need to lock the client keyboard, specially viewing Task manager, can please anyone tell me how to disable it????? please i dont have enough time
Printable View
wish that anyone can help me in this, im working on administration project, and i need to lock the client keyboard, specially viewing Task manager, can please anyone tell me how to disable it????? please i dont have enough time
Private Declare Function BlockInput Lib "user32" (ByVal fBlock As Long) As Long
--
The BlockInput function blocks keyboard and mouse input events from reaching applications.
---
ยท fBlock
[in] Specifies the function's purpose. If this parameter is TRUE, keyboard and mouse input events are blocked. If this parameter is FALSE, keyboard and mouse events are unblocked. Note that only the thread that blocked input can successfully unblock input.
i didnt got it
can you please post a small example on it???? many thanks
VB Code:
Option Explicit Private Declare Function BlockInput Lib "user32" (ByVal fBlock As Long) As Long Private Sub Command1_Click() fBlock (True) End Sub
"Option" is not declared, how can i decleare it???
Just paste these two lines before any subs
VB Code:
Option Explicit Private Declare Function BlockInput Lib "user32" (ByVal fBlock As Long) As Long
Option Explicit tells the IDE that you will declare each variable before you use it. It prevents spelling errors in your code. You can check Require Variable Declaration in the Options page, to have the IDE automatically place it in each form, module, and class. It is highly recommended that you enable this options. It will save you a lot of grief, and get you into good coding habits.
doesnt work yet, can you please send me small example??
this code blocks both keyboard and mouse....can you tell me how to modify it to only block the keyboard?
Nope. You'd have to use the KeyPress event, and set each keypress to 0, to eliminate it. Its not quite as easy.
Show us what you are doing and maybe we can figure out what you are doing incorrectly.Quote:
Originally Posted by Lightmoon1992
many thanks everyone, i solve it by adjusting some values in registry
Ok well I didn't ask the question but maybe you guys can still help me instead.
I saw the code that dark_shadow and ghades posted.Well I can't seem to get their code to work. I keep getting a compile error it says sub or function not defined and highlights my command1_click. CommandButton.I know it is something easy and is right in front of me but I just can't see it. I am useing visual basic 6.0
Below is what I have enter in my frm
VB Code:
Option Explicit Private Declare Function BlockInput Lib "user32" (ByVal fBlock As Long) As Long Private Sub Command1_Click() 'This is what is hightlighted in yellow fBlock (True) 'It also hightlights the fblock in grey End Sub
That wouldn't work. You would block the input, and wouldn't be able to unblock it. Try this sample to see that it works. It uses the sleep api to wait 10 seconds.
VB Code:
Option Explicit Private Declare Function BlockInput Lib "user32" (ByVal fBlock As Long) As Long Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) Private Sub Form_Activate() 'KPD-Team 2000 'URL: [url]http://www.allapi.net/[/url] 'E-Mail: [email][email protected][/email] DoEvents 'block the mouse and keyboard input BlockInput True 'wait 10 seconds before unblocking it Sleep 10000 ' for 10 seconds 'unblock the mouse and keyboard input BlockInput False Unload Me End Sub
ok thxs for the help it works great. IF you really want to help you can take out you brain a give it to me lol jk.
Just hang around here. You'll pick up things, and will be able to help others. It keeps you sharp!
It is brains, yes, but it is also experience and you can't teach that! :)Quote:
Originally Posted by EckoDOG
Hello. Im trying to do the same as them. My skills are not as good as yours, but I have a problem. I have to make a program, which can block the keyboard?
Which codes would you use? :)
Cant simply do something like this?
Code:Private Declare Function GetAsyncKeyState Lib "user32" _
(ByVal vKey As Long) As Integer
Private Sub Timer1_Timer()
Dim KeyResult As Integer
Dim i As Byte
For i = 1 To 254
KeyResult = GetAsyncKeyState(i)
If KeyResult = -32767 Then
If i < 255 Then
MsgBox "apple"
Else
End If
End If
Next
End Sub
http://www.vbforums.com/showthread.php?t=550216