darthblader Posted May 23, 2007 Share Posted May 23, 2007 i would like to know how to disable some keys on the keyboard in vb2005. I am making a gaming program where u chose ur game from a list and then it runs it. but the user must not be able to get onto the OS. I know that it is almost impossible to stop ctrl, alt delete, but i would like to know how to disable alt, ctrl, windows key, and F4. thanks for any help Link to comment https://www.neowin.net/forum/topic/562480-vbnet-disabling-keys/ Share on other sites More sharing options...
0 ramesees Posted May 23, 2007 Share Posted May 23, 2007 Hi You need to have the following function in your code so that your application can trap the keypresses and make them do what you want them to do rather than the operating system default: Protected Overrides Function ProcessDialogKey(ByVal keyData As System.Windows.Forms.Keys) As Boolean Select Case (keyData) Case Keys.Control MessageBox.Show("Controlpressed") Case Keys.Alt Or Keys.F4 MessageBox.Show("Altressed") End Select Return MyBase.ProcessDialogKey(keyData) End Function You will of course need to add more definitions for your own custom purposes. This has been put together quickly, and may not be so accurate. I'm more of a C# developer than VB.NET gayathri 1 Share Link to comment https://www.neowin.net/forum/topic/562480-vbnet-disabling-keys/#findComment-588574521 Share on other sites More sharing options...
0 darthblader Posted May 23, 2007 Author Share Posted May 23, 2007 ah right ok. i have it running here for all my buttons that i need but they continue to run after the messagebox how do u get it to not close down on some of the occassions lol Link to comment https://www.neowin.net/forum/topic/562480-vbnet-disabling-keys/#findComment-588574660 Share on other sites More sharing options...
0 Squirrelington Posted May 23, 2007 Share Posted May 23, 2007 i remember doing this ages ago in VB6 in an attempt to help someone prevent people using the Windows+U combo to bypass their custom login program, code worked too but they didn't wanna use it (blocked windows from being used until logged in) Link to comment https://www.neowin.net/forum/topic/562480-vbnet-disabling-keys/#findComment-588575197 Share on other sites More sharing options...
0 ramesees Posted May 24, 2007 Share Posted May 24, 2007 darthblader said: ah right ok. i have it running here for all my buttons that i need but they continue to run after the messageboxhow do u get it to not close down on some of the occassions lol I put Return True after the message boxes: Protected Overrides Function ProcessDialogKey(ByVal keyData As System.Windows.Forms.Keys) As Boolean Select Case (keyData) Case Keys.Control MessageBox.Show("Controlpressed") Return True Case Keys.Alt Or Keys.F4 MessageBox.Show("Altressed") Return True End Select Return MyBase.ProcessDialogKey(keyData) End Function which seemed to work here Link to comment https://www.neowin.net/forum/topic/562480-vbnet-disabling-keys/#findComment-588576932 Share on other sites More sharing options...
Question
darthblader
i would like to know how to disable some keys on the keyboard in vb2005.
I am making a gaming program where u chose ur game from a list and then it runs it.
but the user must not be able to get onto the OS.
I know that it is almost impossible to stop ctrl, alt delete, but i would like to know how to disable
alt, ctrl, windows key, and F4.
thanks for any help
Link to comment
https://www.neowin.net/forum/topic/562480-vbnet-disabling-keys/Share on other sites
4 answers to this question
Recommended Posts