Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Visual Basic
  4. capturing and handling keyboard input

capturing and handling keyboard input

Scheduled Pinned Locked Moved Visual Basic
helptutorialquestion
6 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • O Offline
    O Offline
    oakleaf
    wrote on last edited by
    #1

    The project I am working on was built to be used in conjunction with a touchscreen, but due to cost, it now has to work with a regular keyboard and mouse as well. Due to the nature of the project, I have to be able to prevent a user from leaving the application and having access to windows. How would I capture keys such as Ctrl+Alt+Delete and prevent the default behavior? I will also need to prevent Alt+Tab, the windows key, etc. I believe I know how to do the capture.... Private Sub Form1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles MyBase.KeyPress 'Ctrl keypress If e.KeyChar = ChrW(17) Then 'then what? End If End Sub Really going to need some help here.. Has anyone done something similar?

    O 1 Reply Last reply
    0
    • O oakleaf

      The project I am working on was built to be used in conjunction with a touchscreen, but due to cost, it now has to work with a regular keyboard and mouse as well. Due to the nature of the project, I have to be able to prevent a user from leaving the application and having access to windows. How would I capture keys such as Ctrl+Alt+Delete and prevent the default behavior? I will also need to prevent Alt+Tab, the windows key, etc. I believe I know how to do the capture.... Private Sub Form1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles MyBase.KeyPress 'Ctrl keypress If e.KeyChar = ChrW(17) Then 'then what? End If End Sub Really going to need some help here.. Has anyone done something similar?

      O Offline
      O Offline
      oakleaf
      wrote on last edited by
      #2

      Have also tried: If Control.ModifierKeys = Keys.ControlKey Then e.Handled = True Microsoft.VisualBasic.Interaction.Beep() End If If Control.ModifierKeys = Keys.Alt Then e.Handled = True Microsoft.VisualBasic.Interaction.Beep() End If If Control.ModifierKeys = Keys.Control Then e.Handled = True Microsoft.VisualBasic.Interaction.Beep() End If If Control.ModifierKeys = Keys.Escape Then e.Handled = True Microsoft.VisualBasic.Interaction.Beep() End If If Control.ModifierKeys = Keys.RWin Then e.Handled = True Microsoft.VisualBasic.Interaction.Beep() End If If Control.ModifierKeys = Keys.LWin Then e.Handled = True Microsoft.VisualBasic.Interaction.Beep() End If but the default behavior still runs

      D 1 Reply Last reply
      0
      • O oakleaf

        Have also tried: If Control.ModifierKeys = Keys.ControlKey Then e.Handled = True Microsoft.VisualBasic.Interaction.Beep() End If If Control.ModifierKeys = Keys.Alt Then e.Handled = True Microsoft.VisualBasic.Interaction.Beep() End If If Control.ModifierKeys = Keys.Control Then e.Handled = True Microsoft.VisualBasic.Interaction.Beep() End If If Control.ModifierKeys = Keys.Escape Then e.Handled = True Microsoft.VisualBasic.Interaction.Beep() End If If Control.ModifierKeys = Keys.RWin Then e.Handled = True Microsoft.VisualBasic.Interaction.Beep() End If If Control.ModifierKeys = Keys.LWin Then e.Handled = True Microsoft.VisualBasic.Interaction.Beep() End If but the default behavior still runs

        D Offline
        D Offline
        Dave Kreskowiak
        wrote on last edited by
        #3

        There is no way to stop Ctrl-Alt-Delete or Alt-Tab or any other system combination from popping up from your code. Those key combinations are handled by the system before your app even knows that the final key in the combination was even pressed. For example, your app will known that Ctrl and Alt are held down, but will never see the Del key. It will know that Alt is down, but not the Tab key. Most of these things are best handled by modifying Group Policy on the machine. Some, like disabling the Windows key are better left to a C++ app that uses a low-level keyboard hook and eats certain keys. Still, there's no way to stop Ctrl-Alt-Del from popping up. But, by using Group Policy, you can stop everything the user can do in the dialog that pops up. I would HIGHLY suggest picking up the Resource Kit for what OS your using for your kiosk. It'll prove to be invaluable in a case like this. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

        O 1 Reply Last reply
        0
        • D Dave Kreskowiak

          There is no way to stop Ctrl-Alt-Delete or Alt-Tab or any other system combination from popping up from your code. Those key combinations are handled by the system before your app even knows that the final key in the combination was even pressed. For example, your app will known that Ctrl and Alt are held down, but will never see the Del key. It will know that Alt is down, but not the Tab key. Most of these things are best handled by modifying Group Policy on the machine. Some, like disabling the Windows key are better left to a C++ app that uses a low-level keyboard hook and eats certain keys. Still, there's no way to stop Ctrl-Alt-Del from popping up. But, by using Group Policy, you can stop everything the user can do in the dialog that pops up. I would HIGHLY suggest picking up the Resource Kit for what OS your using for your kiosk. It'll prove to be invaluable in a case like this. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

          O Offline
          O Offline
          oakleaf
          wrote on last edited by
          #4

          Found an article on Managing Low-Level Keyboard Hooks in VB .NET: http://www.developer.com/net/vb/article.php/10926_2193301_3[^] The code works great... but needs some working on.. I am currently using it to successfully block: Ctrl+Escape Alt+Tab Alt+Escape Alt + F4 And the Right/Left Windows keys Just need to get Ctrl+Alt+Delete... I don't doubt that "key combinations are handled by the system before your app even knows that the final key in the combination was even pressed" , but somehow this module seems to work, doing just that(?). Maybe if you had a look at the article?

          D 1 Reply Last reply
          0
          • O oakleaf

            Found an article on Managing Low-Level Keyboard Hooks in VB .NET: http://www.developer.com/net/vb/article.php/10926_2193301_3[^] The code works great... but needs some working on.. I am currently using it to successfully block: Ctrl+Escape Alt+Tab Alt+Escape Alt + F4 And the Right/Left Windows keys Just need to get Ctrl+Alt+Delete... I don't doubt that "key combinations are handled by the system before your app even knows that the final key in the combination was even pressed" , but somehow this module seems to work, doing just that(?). Maybe if you had a look at the article?

            D Offline
            D Offline
            Dave Kreskowiak
            wrote on last edited by
            #5

            I know for a fact that there is absolutely no way on earth you're going to trap Ctrl-Alt-Delete. Unless of course, you replace the GINA.DLL (don't even bother). You can't stop it from popping up, but you can block the actions that can be taken inside the dialog using Group Policies (Start/Run - gpedit.msc.) RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

            O 1 Reply Last reply
            0
            • D Dave Kreskowiak

              I know for a fact that there is absolutely no way on earth you're going to trap Ctrl-Alt-Delete. Unless of course, you replace the GINA.DLL (don't even bother). You can't stop it from popping up, but you can block the actions that can be taken inside the dialog using Group Policies (Start/Run - gpedit.msc.) RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

              O Offline
              O Offline
              oakleaf
              wrote on last edited by
              #6

              Yeah, was just reading that on MSDN.... Gina isn't an option.... now have to modify the registry... Ugh HKCU\ Software\ Microsoft\ Windows\ CurrentVersion\ Policies\ System\DisableTaskMgr = dword:1 thanks

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups