CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2001
    Location
    Philippines
    Posts
    9

    disabling keyboard and mouse

    How can I disable the mouse and Keyboard?What API will I use?

    thx.....
    xnor


  2. #2
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: disabling keyboard and mouse

    Shell "rundll32 keyboard,disable"

    but you have to reboot in order to enable the keyboard
    you can't use enable in this command


    Iouri Boutchkine
    [email protected]
    Iouri Boutchkine
    [email protected]

  3. #3
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: disabling keyboard and mouse

    'that will disable keyboard only for this application

    Dim flag_ed As Boolean
    Private Sub Command1_Click()
    flag_ed = Not flag_ed
    If flag_ed Then
    Command1.Caption = "Disable KeyBoard"
    Else
    Command1.Caption = "Enable KeyBoard"
    End If
    End Sub


    Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    If flag_ed Then
    Else
    KeyCode = 0
    End If
    End Sub

    Private Sub Form_KeyPress(KeyAscii As Integer)
    If flag_ed Then
    Else
    KeyAscii = 0
    End If
    End Sub

    Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
    If flag_ed Then
    Else
    KeyCode = 0
    End If
    End Sub

    Private Sub Form_Load()
    flag_ed = True
    Command1.Caption = "Disable KeyBoard"
    End Sub




    Iouri Boutchkine
    [email protected]
    Iouri Boutchkine
    [email protected]

  4. #4
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: disabling keyboard and mouse

    I don't know how to disabnle a mouse, but an alternative way is to hide the pointer


    Declare Function ShowCursor& Lib "user32" _
    (ByVal bShow As Long)
    'Add this code to Command1.


    Private Sub Command1_Click()
    ShowCursor (bShow = True)
    End Sub


    Private Sub Command2_Click()
    ShowCursor (bShow = False)
    End Sub


    Iouri Boutchkine
    [email protected]
    Iouri Boutchkine
    [email protected]

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

Featured