Results 1 to 18 of 18

Thread: how can i disable keyboard?????? please help

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Dec 2005
    Posts
    26

    Exclamation how can i disable keyboard?????? please help

    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

  2. #2
    Junior Member
    Join Date
    Oct 2004
    Posts
    26

    Re: how can i disable keyboard?????? please help

    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.
    U`ll Never Get To HEAVEN If U`re Scared Of Gettin` HIGH

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Dec 2005
    Posts
    26

    Exclamation Re: how can i disable keyboard?????? please help

    i didnt got it

    can you please post a small example on it???? many thanks

  4. #4
    Fanatic Member dark_shadow's Avatar
    Join Date
    Feb 2005
    Location
    Igloo
    Posts
    900

    Re: how can i disable keyboard?????? please help

    VB Code:
    1. Option Explicit
    2. Private Declare Function BlockInput Lib "user32" (ByVal fBlock As Long) As Long
    3.  
    4. Private Sub Command1_Click()
    5. fBlock (True)
    6. End Sub

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Dec 2005
    Posts
    26

    Exclamation Re: how can i disable keyboard?????? please help

    "Option" is not declared, how can i decleare it???

  6. #6
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: how can i disable keyboard?????? please help

    Just paste these two lines before any subs
    VB Code:
    1. Option Explicit
    2. 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.

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Dec 2005
    Posts
    26

    Exclamation Re: how can i disable keyboard?????? please help

    doesnt work yet, can you please send me small example??

  8. #8
    New Member
    Join Date
    Jun 2000
    Posts
    4

    Re: how can i disable keyboard?????? please help

    this code blocks both keyboard and mouse....can you tell me how to modify it to only block the keyboard?

  9. #9
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: how can i disable keyboard?????? please help

    Nope. You'd have to use the KeyPress event, and set each keypress to 0, to eliminate it. Its not quite as easy.

  10. #10
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: how can i disable keyboard?????? please help

    Quote Originally Posted by Lightmoon1992
    doesnt work yet, can you please send me small example??
    Show us what you are doing and maybe we can figure out what you are doing incorrectly.

  11. #11

    Thread Starter
    Junior Member
    Join Date
    Dec 2005
    Posts
    26

    Exclamation Re: how can i disable keyboard?????? please help

    many thanks everyone, i solve it by adjusting some values in registry

  12. #12
    New Member EckoDOG's Avatar
    Join Date
    Dec 2005
    Location
    marz
    Posts
    8

    Re: how can i disable keyboard?????? please help

    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:
    1. Option Explicit
    2. Private Declare Function BlockInput Lib "user32" (ByVal fBlock As Long) As Long
    3.  
    4. Private Sub Command1_Click() 'This is what is hightlighted in yellow
    5. fBlock (True) 'It also hightlights the fblock in grey
    6. End Sub

  13. #13
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: how can i disable keyboard?????? please help

    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:
    1. Option Explicit
    2.  
    3. Private Declare Function BlockInput Lib "user32" (ByVal fBlock As Long) As Long
    4. Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
    5.  
    6. Private Sub Form_Activate()
    7.     'KPD-Team 2000
    8.     'URL: [url]http://www.allapi.net/[/url]
    9.     'E-Mail: [email][email protected][/email]
    10.     DoEvents
    11.     'block the mouse and keyboard input
    12.     BlockInput True
    13.     'wait 10 seconds before unblocking it
    14.     Sleep 10000 ' for 10 seconds
    15.     'unblock the mouse and keyboard input
    16.     BlockInput False
    17.     Unload Me
    18. End Sub

  14. #14
    New Member EckoDOG's Avatar
    Join Date
    Dec 2005
    Location
    marz
    Posts
    8

    Re: how can i disable keyboard?????? please help

    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.

  15. #15
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: how can i disable keyboard?????? please help

    Just hang around here. You'll pick up things, and will be able to help others. It keeps you sharp!

  16. #16
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: how can i disable keyboard?????? please help

    Quote Originally Posted by EckoDOG
    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.
    It is brains, yes, but it is also experience and you can't teach that!

  17. #17
    New Member
    Join Date
    Nov 2008
    Posts
    1

    Re: how can i disable keyboard?????? please help

    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?

  18. #18
    Lively Member
    Join Date
    Jan 2008
    Posts
    114

    Re: how can i disable keyboard?????? please help

    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
    Last edited by Pezster; Dec 19th, 2008 at 11:25 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width