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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Enable/Disable Keyboard

Status
Not open for further replies.

Hackster

Programmer
Mar 28, 2001
173
0
0
US
Does anyone know, programmatically, how to disable, then reenable, the keyboard? I know how to do that with the mouse, but I have an app for which I need to be able to disable and reenable both.
 
Perhaps something like this will have the same effect:

on the Keypress event (to be repeated for all text box controls):

Private Sub txtBox_KeyPress(KeyAscii As Integer)
Dim Char
Char = Chr(KeyAscii)
KeyAscii = Asc(0) or other "empty" ASCII code
End Sub

Let me know the result at
vincent.mairiaux@yucom.be

Vincent from Antwerp/Belgium
 
There is no GOOD reason to disable the KEYBOARD! There are several UNDOCUMENTED ways to do so. If you want to intercept key-strokes, that one thing. But disable the KEYBOARD?, I don't think so. Sounds like your trying to hatch a VIRUS to me!!!! If not, then please be more specific in what you are trying to do. Tim

Remember the KISS principle:
Keep It Simple, Stupid!
 
I agree that there is no GOOD reason for disabling the keyboard. It wasn't my idea. It was a management requirement. Do I need to say more? I have a program which I put into production shortly after I submitted this post. This program runs in a kiosk. Actually, it runs in 5 different kiosks, one on each floor of the building that I'm in. Management decided that they wanted both the mouse and keyboard disabled so someone couldn't walk on by and just shut the thing down.

This post was actually a consession to them. I promised I'd try to find out how to do it.
 
Umm....... Lock up the mouse & KB inside the kiosk.?
if the KB was disabled, how would a legitimate KB user(programmer, manager, salesperson etc.) be able to use it? Tim

Remember the KISS principle:
Keep It Simple, Stupid!
 
The only ones requiring access to it is the programmer (me), and I have the source code. At the moment, all it does it scroll information regarding company direction, HR stuff, and things like that. It is for viewing only. I'd never say this to the folks around here, but the whole way they had me set this up is dumb, and I don't think anyone is going to find it very useful. But...I'm just your humble programmer following his specs... (Actually, the keyboard really isn't locked, but no one knows that. I built in a key combination that will "unlock" it. I had to. The way updates were supposed to be performed was to physically power off the machine which is a really dumb idea.)
 
Well, for a silly idea...

Why don't you just run the program and reach behind the computer and unplug the keyboard? Or hide the keyboard in a cabinet?

I also don't think it's a good idea to "lock" a keyboard.

Kevin
 
unplug the keyboard?

If you really dont want any1 going into that system, do a password lock with the screensaver. Your program should still be functioning in the background.
 
Unplugged the keyboard is a no-no, and there is no screen saver running on the workstations.
 
Why not just make the form take up the whole screen and then set

form1.enabled = false

 
Your situation sounds terrible. If managements wants to protect the software so that no one touches it, they should really re-think their idea. Software lock isn't the answer b/c if I really wanted to mess with that computer, I still can. There's so many other ways to do it...power button for example.

When making the form take up the whole screen and disabling the form, can't I still Ctrl-Alt-Del and shut it down? I guess it would depend on the technical level of the individuals around your area. I dont think this idea would stop members of this forum from killing a program like that since we are all technical users.

Good luck Hackster. May the Force be with you. :)
 
I don't know, the whole thing seems like they should just build a seperate room for the computer running the program, complete with A/C, and 440 volts power, run REALLY long VGA cables through a splitter, to each freakin monitor so that there is no mouse, keyboard, computer, near the monitor because it's all locked up in a seperate room with steel-reinforced concrete and laser beams that poke you in the eye with nerf darts if you are an intruder... Then it'll drop green goop all over you. Management should buy that.

Oh... and the floor should be surrounded by land mines. Or is this too much?

Kevin
 
Hi,

You can hide your application from the CTRL-ALT-DEL list, so thats not really a problem and since there is a keyboard lock, how on earth would someone be able to press CTRL-ALT-DEL... If they reboot (which seems unlikely, because the towers are most of the times covered behind locks), the application will load again if you simply add a registry key.

Anyway, I think you should make a system wide hook in C++ and return -1 for a keypress or mousepress. If you do that, there wont be any keyevents or mouseevents at all and you can still process the events.

LuCkY
 
You can easily disable the keyboard with:
[tt]Shell "rundll32 keyboard,disable"[/tt]
Re-enabling it isn't so simple LOL.

LuckyLuke may have a workable idea (if you feel up to coding a C++ DLL). As long as you aren't worried about background processing, a simpler (not-so-efficient) way may be to use [tt]GetAsyncKeyState[/tt] in a fast timer and use [tt]SendKeys "^Z"[/tt] every time a new key is pressed.

AUGGHHH! I can't believe I suggested that!
VCA.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top