• 0

(VB.net) Disabling keys


Question

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

  • 0

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

  • 0

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)

  • 0
  darthblader said:
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

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

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • I think they needed to simplify their product lines, having such a range of devices is confusing at best, and yes, I think it's also worth dropping those old line names. So I think it's good for them in the long run, and I bet they found that in their research too. Ask a random consumer which of their products would have been the premium one, and unless they knew Dell products intimately, I doubt they would know. Though I think they could have simplified it further.. "Pro Max Plus", what the hell is going on there?!
    • Wrong again. Electric vehicles are more reliable than gasoline vehicles because they have fewer points of failure. On average, they last 50% longer. Its your right to be incorrect and my right to correct you.
    • Hello, I am using a Hitron CODA56 cable modem with Comcast Xfinity's 1200 Mbps service.  No issues noted.  I had looked at the Motorola and Netgear options for a cable modem, but neither was available for purchase at the time I upgraded my cable connection. There are multiple models in the Netgear Nighthawk X10 line-up.  I am guessing you have either the the Netgear Nighthawk X10 AD7000 model (R8900) or the Netgear Nighthawk X10 AD7200 model (R9000) model, is that correct?  Both of these only have one gigabit WAN (internet) ports for connection to the modem, all of the remaining ports for the LAN side of things are gigabit Ethernet ports.  The 10GbE port on the devices is meant for connection to local NAS storage.  I suppose you could connect the desktop computer directly to it, although it would still be limited by the gigabit connection between the cable modem and the Netgear residential gateway broadband router. I would suggest looking for a residential gateway broadband router from a company like Asus, Netgear, TP-Link or maybe even Ubiquiti, depending upon budget, that has 2.5Gbps (or faster) WAN and LAN ports.  That would allow you to make full use of the 1.2Gbps connection from your ISP as well as have some room for future growth, speed-wise. Regards, Aryeh Goretsky      
  • Recent Achievements

    • Week One Done
      Marites earned a badge
      Week One Done
    • One Year In
      runge100 earned a badge
      One Year In
    • One Month Later
      runge100 earned a badge
      One Month Later
    • One Month Later
      jfam earned a badge
      One Month Later
    • First Post
      TheRingmaster earned a badge
      First Post
  • Popular Contributors

    1. 1
      +primortal
      575
    2. 2
      ATLien_0
      183
    3. 3
      +FloatingFatMan
      178
    4. 4
      Michael Scrip
      134
    5. 5
      Xenon
      119
  • Tell a friend

    Love Neowin? Tell a friend!