how to use keydown with combinations of keycode (1 Viewer)

AccessProgram

Registered User.
Local time
Today, 12:50
Joined
Dec 7, 2009
Messages
68
I have found the code below to disable some keys.

Is there a combination of keycode that will disable ctrl+alt+delete and alt+tab?


Code:

Public Function DisableKeys(KeyCode As Integer)
Select Case KeyCode
Case vbKeyF1 'F1 Key
KeyCode = 0 'Makes it so that if user presses this key it will do nothing
Case vbKeyF2
KeyCode = 0
Case vbKeyF3
KeyCode = 0
Case vbKeyF4
KeyCode = 0
Case vbKeyF5
KeyCode = 0
Case vbKeyF6
KeyCode = 0
Case vbKeyF7
KeyCode = 0
Case vbKeyF8
KeyCode = 0
Case vbKeyF9
KeyCode = 0
Case vbKeyF10
KeyCode = 0
Case vbKeyF11
KeyCode = 0
Case vbKeyF12
KeyCode = 0
Case vbKeyHome 'Home Key
KeyCode = 0
Case vbKeyInsert 'Insert Key
KeyCode = 0
Case vbKeyPageDown 'Page Down
KeyCode = 0
Case vbKeyPageUp 'Page Up
KeyCode = 0
Case vbKeyDelete 'Delete
KeyCode = 0
Case vbKeyControl 'Ctrl
KeyCode = 0
Case vbKeyShift 'Shift
KeyCode = 0
Case vbKeyReturn 'Enter
KeyCode = 0
Case vbKeyLeft 'Left Arrow
KeyCode = 0
Case vbKeyRight 'Right Arrow
KeyCode = 0
Case vbKeyUp 'Up Arrow
KeyCode = 0
Case vbKeyDown 'Down Arrow
KeyCode = 0
Case vbKeyEscape 'Escape Key
KeyCode = 0
End Select

End Function
 

ChrisO

Registered User.
Local time
Tomorrow, 05:50
Joined
Apr 30, 2003
Messages
3,202
Do you want to do it for an entire Form or a Text Box?
 

AccessProgram

Registered User.
Local time
Today, 12:50
Joined
Dec 7, 2009
Messages
68
I want to know how to do it on the entire form and on a text box also.
 

ChrisO

Registered User.
Local time
Tomorrow, 05:50
Joined
Apr 30, 2003
Messages
3,202
If you do it on an entire Form there should be no need to do it on a Text Box also.
 

AccessProgram

Registered User.
Local time
Today, 12:50
Joined
Dec 7, 2009
Messages
68
ok. but regardless where I am going to use it, may I know what should be the keycode that will disable ctrl+alt+delete and alt+tab?
 
Local time
Today, 14:50
Joined
Mar 4, 2008
Messages
3,856
These are OS commands, not Access commands. You must do it at the OS level.

With a simple google search I found this:
http://support.microsoft.com/kb/161133

I don't think it's a good idea to do it in Access, but the demo should allow you to do it in VBA (not in the key-down event, though). Notice that Microsoft does not recommend you do this.

I'm sure with just a little more google work than I did, you can find out how to do it for MS OSs that are not listed.
 

AccessProgram

Registered User.
Local time
Today, 12:50
Joined
Dec 7, 2009
Messages
68
Thanks but I really needed that somehow done with keydown event.

What could be the vbkey for ALT in the keyboard?
 
Last edited:

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 14:50
Joined
Feb 28, 2001
Messages
27,165
Don't do it that way. CTRL+ALT+DEL is sacred to Microsoft. ALT+TAB is close to sacred.

You can get the same effect by intercept the form.EXIT event and disallowing it. The EXIT event has a CANCEL parameter that could be set to TRUE to block any attempt to exit from the form.

It is FAR beyond unwise to try to intercept the three-fingered salute. That is your only recourse short of pulling the plug if your system goes whack-a-doodle and you cannot otherwise get back control.

Not only that, but I believe there are some obscure issues with modal dialogs using the MSGBOX functions.

I'll take it one step farther. If you lock out CTL/ALT/DEL operations, you will be unable to get Microsoft support without paying one very pretty penny. The very first thing they will tell you is "Don't do that."

Now, the next obvious question is "WHY NOT?" Answer: Because what you are trying to do by blocking CTL/ATL/DEL is to override the Operating System and take over the machine. On a free-standing, non-networked machine, that might be OK, but if you are in a domain-controlled, multi-user network with workstations that can log in from anywhere to get the same applications, that is NOT OK and might result in system instability, which WILL (not might, but WILL) lead to system crashes and data loss. It might also lead to corruption of the database.

Moral of the story: I don't care HOW badly you need to do this. You don't need to do it no matter how important you think it is. If your job depends on this working and being stable, start reading the want ads immediately.
 

ghudson

Registered User.
Local time
Today, 15:50
Joined
Jun 8, 2002
Messages
6,195
I would find out why your users are killing your open database by using the Ctrl+Alt+Del. Then educate them on why they should not do it [too easy to corrupt a db] unless absolutely necessary for there are times Access just gets locked up.

Besides, trapping for the Ctrl+Alt+Del combo only works while your database has the focus, users can easily Alt+Tab to another window and do the Ctrl+Alt+Del combo and then select your database from the task list and kill it from there.

If you want to find out who is not properly exiting your database, store the users info [time in, users name, compute name, etc] in a table when they open the db and then tag the exit time to the record when they exit the db.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 14:50
Joined
Feb 28, 2001
Messages
27,165
Well said, GH.

I've always found that identifying a culprit and calling in a professional (like Lady Heather from CSI?) for the punishment was usually effective.

To be honest, I've only had to do that kind of thing once, and the punishment was a formal letter of reprimand plus notice of probation. But I also made it known as to WHY the person had his ears pinned back.

Obviously, the question is to solve a problem, but users are a pernicious lot. Can't live with 'em, have no job without 'em. What's a designer to do? Answer: You can't prevent the unthinkable, but there is a good chance of at least publicly laying the blame for it. When all else fails, ridicule works.

Next question: WHY did the person think CTL/ALT/DEL was required? Fix THAT and maybe the unacceptable practice will cease.
 

Banana

split with a cherry atop.
Local time
Today, 12:50
Joined
Sep 1, 2005
Messages
6,318
One more point.

Let's pretend you suceeded in inventing a foolproof method for suppressing the three finger salute. Can we cheer and proclaim the problem solved? No. The users will decide to pull the power cord instead.

Good luck with THAT!

So, yes, heed Ghudson & The_Doc_Man and work out the real reason why your users are doing this instead of frustrating them.
 
Local time
Today, 14:50
Joined
Mar 4, 2008
Messages
3,856
Back in the early 90s I had a similar problem. We were putting single-use computers out in the field in the desert. The project manager was adamant that the users were not to be able to play games or get into any other application than the application I was writing.

We were running Windows for Pen back then. You cannot believe the number of hoops we had to jump through to prevent users from connecting a keyboard and "finding a way" to play games (because they knew how). Add to that multiple "environments" (LAN vs. private radio) and IP before people knew what IP was...

Of course, bypassing all the Windows handles and forcing non-standard hardware to work with it created a whole new set of problems that required a whole new set of solutions which created a whole new set of problems. By the time the project was finished, I felt like I knew more about writing operating systems than I did about writing business applications. I certainly brushed up on my machine language skills.

Since operating systems have improved, Microsoft has developed a security model that allows system administrators to block applications and functions that the company doesn't want the users using.

Are you sure you can't use the security model and profiles to do what you need done?
 

AccessProgram

Registered User.
Local time
Today, 12:50
Joined
Dec 7, 2009
Messages
68
This is actually not a project but only as a desktop security of my computer.
You are right banana, any user can unplug the computer but I have my the application run first before logging in the computer. This is aside from the login procedure of windows.

Anyway, I have found a way that will block the ctrl+alt+del without the taskmgr / taskbmgr message appearing. I found the answer thru so much googling research because.
 

genesis

Registered User.
Local time
Today, 12:50
Joined
Jun 11, 2009
Messages
205
As I have noticed and as I have seen one other poster here, you can get much EXACT help on what you need but instead comments and questions on why you are doing this things.
 

Brianwarnock

Retired
Local time
Today, 20:50
Joined
Jun 2, 2003
Messages
12,701
As I have noticed and as I have seen one other poster here, you can get much EXACT help on what you need but instead comments and questions on why you are doing this things.

Questioning why a person wants to do something helps us to give the correct answer, which, as in this case, might be don't.

Brian
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 14:50
Joined
Feb 28, 2001
Messages
27,165
The reason we comment is because sometimes someone asks questions that go down a very unwise path. This in turn occurs because most users who gravitate to this site are no so widely experienced as we are.

Ambrose Bierce defined "experience" as "the ability to recognize our mistakes when we make them again." But we can ALSO recognize our mistakes when someone else talks about things that would lead down the same garden path we have already traversed. We also have discovered a lot of workarounds, not all of which are appropriate in all situations.

It is for this latter reason that we advise or comment or ask for more details. We want to know if the original poster (OP) is doing something for which we have found a good workaround. If so, we share what works. If not, we might back off or simply advise of the danger associated with the intended path.

Like it or not, it is the price of asking someone else's advice when they don't know the details of your problem and don't know your level of experience. You get the good, the bad, and the ugly. But then again, you paid nothing to get it. So your problem is...?
 

Users who are viewing this thread

Top Bottom