Lock/Disable Keyboard VS2008 VB.NET

Posted on 2011-09-30
Medium Priority
Last Modified: 2012-05-12
I am working on an application that I am in need of locking out the keyboard only.  How can this be done.

I am only interested in locking out the keyboard on a system level not the mouse.

Thanks in advance!
Question by:H-SC
  • 2
  • 2
LVL 83

Accepted Solution

CodeCruiser earned 2000 total points
ID: 36891833

Expert Comment

ID: 36894835
In addition to those articles, if you want to always handle the event you can just check if the ncode is greater than zero, if so return CallNextHookEx() otherwise just return 1 in your KeyboardHookCallback.

In case you need to do anything based on the which key was pressed (exit the application for example especially while debugging)
If you are using framework 3.0 or greater check out the KeyInterop Class methods in WindowsBase.dll

Otherwise, I have observed that many of the keycodes coincide with the windows forms Keys enumeration (beware though some do not match up, such as the number pad keys):
Dim vkCode As Integer = Marshal.ReadInt32(lParam)
Dim key As Forms.Keys = CType(vkCode, Forms.Keys)

Open in new window

Best of luck.

Author Comment

ID: 36903091

This is great info, many thanks for your reply

Author Comment

ID: 36903096

I think that I am going with the second link that you posted.  It seems more adaptable to what I am needing.  It looks like it will work great.  many thanks.
LVL 83

Expert Comment

ID: 36906370
Glad to help :-)

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
An ASP.NET Web Form User Control is not newly introduced in ASP.NET. In fact, it was an old technology yet still playing a role to generate web content, especially when we want to use it to have a better and easy way to control part of the web conte…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Hi, this video explains a free download that you can incorporate into your Access databases, or use stand-alone for contact management. Contacts -- Names, Addresses, Phone Numbers, eMail Addresses, Websites, Lists, Projects, Notes, Attachments…

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question