Thread Rating:
  • 4 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to hook the keyboard. [VB.NET] [TuT]
#33
Good Source
If You don't mind
I just post something i added to determine if caps or shift key is holded:

Quote:Private Sub kbHook_KeyDown(ByVal Key As System.Windows.Forms.Keys) Handles kbHook.KeyDown
If TextBox2.Text = "False" Then
If TextBox3.Text = "False" Then
If Key = Keys.A Then
TextBox1.Text = TextBox1.Text & "a"
ElseIf Key = Keys.B Then
TextBox1.Text = TextBox1.Text & "b"
ElseIf Key = Keys.C Then
TextBox1.Text = TextBox1.Text & "c"
ElseIf Key = Keys.D Then
TextBox1.Text = TextBox1.Text & "d"
ElseIf Key = Keys.E Then
TextBox1.Text = TextBox1.Text & "e"
ElseIf Key = Keys.F Then
TextBox1.Text = TextBox1.Text & "f"
ElseIf Key = Keys.G Then
TextBox1.Text = TextBox1.Text & "g"
ElseIf Key = Keys.H Then
TextBox1.Text = TextBox1.Text & "h"
ElseIf Key = Keys.I Then
TextBox1.Text = TextBox1.Text & "i"
ElseIf Key = Keys.J Then
TextBox1.Text = TextBox1.Text & "j"
ElseIf Key = Keys.K Then
TextBox1.Text = TextBox1.Text & "k"
ElseIf Key = Keys.L Then
TextBox1.Text = TextBox1.Text & "l"
ElseIf Key = Keys.M Then
TextBox1.Text = TextBox1.Text & "m"
ElseIf Key = Keys.N Then
TextBox1.Text = TextBox1.Text & "n"
ElseIf Key = Keys.O Then
TextBox1.Text = TextBox1.Text & "o"
ElseIf Key = Keys.P Then
TextBox1.Text = TextBox1.Text & "p"
ElseIf Key = Keys.Q Then
TextBox1.Text = TextBox1.Text & "q"
ElseIf Key = Keys.R Then
TextBox1.Text = TextBox1.Text & "r"
ElseIf Key = Keys.S Then
TextBox1.Text = TextBox1.Text & "s"
ElseIf Key = Keys.T Then
TextBox1.Text = TextBox1.Text & "t"
ElseIf Key = Keys.U Then
TextBox1.Text = TextBox1.Text & "u"
ElseIf Key = Keys.V Then
TextBox1.Text = TextBox1.Text & "v"
ElseIf Key = Keys.W Then
TextBox1.Text = TextBox1.Text & "w"
ElseIf Key = Keys.X Then
TextBox1.Text = TextBox1.Text & "x"
ElseIf Key = Keys.Y Then
TextBox1.Text = TextBox1.Text & "y"
ElseIf Key = Keys.Z Then
TextBox1.Text = TextBox1.Text & "z"
ElseIf Key = Keys.Space Then
TextBox1.Text = TextBox1.Text & " "

End If
End If
End If
If TextBox2.Text = "False" Then
If TextBox3.Text = "True" Then
If Key = Keys.A Then
TextBox1.Text = TextBox1.Text & "A"
ElseIf Key = Keys.B Then
TextBox1.Text = TextBox1.Text & "B"
ElseIf Key = Keys.C Then
TextBox1.Text = TextBox1.Text & "C"
ElseIf Key = Keys.D Then
TextBox1.Text = TextBox1.Text & "D"
ElseIf Key = Keys.E Then
TextBox1.Text = TextBox1.Text & "E"
ElseIf Key = Keys.F Then
TextBox1.Text = TextBox1.Text & "F"
ElseIf Key = Keys.G Then
TextBox1.Text = TextBox1.Text & "G"
ElseIf Key = Keys.H Then
TextBox1.Text = TextBox1.Text & "H"
ElseIf Key = Keys.I Then
TextBox1.Text = TextBox1.Text & "I"
ElseIf Key = Keys.J Then
TextBox1.Text = TextBox1.Text & "J"
ElseIf Key = Keys.K Then
TextBox1.Text = TextBox1.Text & "K"
ElseIf Key = Keys.L Then
TextBox1.Text = TextBox1.Text & "L"
ElseIf Key = Keys.M Then
TextBox1.Text = TextBox1.Text & "M"
ElseIf Key = Keys.N Then
TextBox1.Text = TextBox1.Text & "N"
ElseIf Key = Keys.O Then
TextBox1.Text = TextBox1.Text & "O"
ElseIf Key = Keys.P Then
TextBox1.Text = TextBox1.Text & "P"
ElseIf Key = Keys.Q Then
TextBox1.Text = TextBox1.Text & "Q"
ElseIf Key = Keys.R Then
TextBox1.Text = TextBox1.Text & "R"
ElseIf Key = Keys.S Then
TextBox1.Text = TextBox1.Text & "S"
ElseIf Key = Keys.T Then
TextBox1.Text = TextBox1.Text & "T"
ElseIf Key = Keys.U Then
TextBox1.Text = TextBox1.Text & "U"
ElseIf Key = Keys.V Then
TextBox1.Text = TextBox1.Text & "V"
ElseIf Key = Keys.W Then
TextBox1.Text = TextBox1.Text & "W"
ElseIf Key = Keys.X Then
TextBox1.Text = TextBox1.Text & "X"
ElseIf Key = Keys.Y Then
TextBox1.Text = TextBox1.Text & "Y"
ElseIf Key = Keys.Z Then
TextBox1.Text = TextBox1.Text & "Z"
ElseIf Key = Keys.Space Then
TextBox1.Text = TextBox1.Text & " "
End If
End If
End If

If TextBox2.Text = "True" Then
If TextBox3.Text = "True" Then
If Key = Keys.A Then
TextBox1.Text = TextBox1.Text & "a"
ElseIf Key = Keys.B Then
TextBox1.Text = TextBox1.Text & "b"
ElseIf Key = Keys.C Then
TextBox1.Text = TextBox1.Text & "c"
ElseIf Key = Keys.D Then
TextBox1.Text = TextBox1.Text & "d"
ElseIf Key = Keys.E Then
TextBox1.Text = TextBox1.Text & "e"
ElseIf Key = Keys.F Then
TextBox1.Text = TextBox1.Text & "f"
ElseIf Key = Keys.G Then
TextBox1.Text = TextBox1.Text & "g"
ElseIf Key = Keys.H Then
TextBox1.Text = TextBox1.Text & "h"
ElseIf Key = Keys.I Then
TextBox1.Text = TextBox1.Text & "i"
ElseIf Key = Keys.J Then
TextBox1.Text = TextBox1.Text & "j"
ElseIf Key = Keys.K Then
TextBox1.Text = TextBox1.Text & "k"
ElseIf Key = Keys.L Then
TextBox1.Text = TextBox1.Text & "l"
ElseIf Key = Keys.M Then
TextBox1.Text = TextBox1.Text & "m"
ElseIf Key = Keys.N Then
TextBox1.Text = TextBox1.Text & "n"
ElseIf Key = Keys.O Then
TextBox1.Text = TextBox1.Text & "o"
ElseIf Key = Keys.P Then
TextBox1.Text = TextBox1.Text & "p"
ElseIf Key = Keys.Q Then
TextBox1.Text = TextBox1.Text & "q"
ElseIf Key = Keys.R Then
TextBox1.Text = TextBox1.Text & "r"
ElseIf Key = Keys.S Then
TextBox1.Text = TextBox1.Text & "s"
ElseIf Key = Keys.T Then
TextBox1.Text = TextBox1.Text & "t"
ElseIf Key = Keys.U Then
TextBox1.Text = TextBox1.Text & "u"
ElseIf Key = Keys.V Then
TextBox1.Text = TextBox1.Text & "v"
ElseIf Key = Keys.W Then
TextBox1.Text = TextBox1.Text & "w"
ElseIf Key = Keys.X Then
TextBox1.Text = TextBox1.Text & "x"
ElseIf Key = Keys.Y Then
TextBox1.Text = TextBox1.Text & "y"
ElseIf Key = Keys.Z Then
TextBox1.Text = TextBox1.Text & "z"
ElseIf Key = Keys.Space Then
TextBox1.Text = TextBox1.Text & " "
End If
End If
End If
If TextBox2.Text = "True" Then
If TextBox3.Text = "False" Then
If Key = Keys.A Then
TextBox1.Text = TextBox1.Text & "A"
ElseIf Key = Keys.B Then
TextBox1.Text = TextBox1.Text & "B"
ElseIf Key = Keys.C Then
TextBox1.Text = TextBox1.Text & "C"
ElseIf Key = Keys.D Then
TextBox1.Text = TextBox1.Text & "D"
ElseIf Key = Keys.E Then
TextBox1.Text = TextBox1.Text & "E"
ElseIf Key = Keys.F Then
TextBox1.Text = TextBox1.Text & "F"
ElseIf Key = Keys.G Then
TextBox1.Text = TextBox1.Text & "G"
ElseIf Key = Keys.H Then
TextBox1.Text = TextBox1.Text & "H"
ElseIf Key = Keys.I Then
TextBox1.Text = TextBox1.Text & "I"
ElseIf Key = Keys.J Then
TextBox1.Text = TextBox1.Text & "J"
ElseIf Key = Keys.K Then
TextBox1.Text = TextBox1.Text & "K"
ElseIf Key = Keys.L Then
TextBox1.Text = TextBox1.Text & "L"
ElseIf Key = Keys.M Then
TextBox1.Text = TextBox1.Text & "M"
ElseIf Key = Keys.N Then
TextBox1.Text = TextBox1.Text & "N"
ElseIf Key = Keys.O Then
TextBox1.Text = TextBox1.Text & "O"
ElseIf Key = Keys.P Then
TextBox1.Text = TextBox1.Text & "P"
ElseIf Key = Keys.Q Then
TextBox1.Text = TextBox1.Text & "Q"
ElseIf Key = Keys.R Then
TextBox1.Text = TextBox1.Text & "R"
ElseIf Key = Keys.S Then
TextBox1.Text = TextBox1.Text & "S"
ElseIf Key = Keys.T Then
TextBox1.Text = TextBox1.Text & "T"
ElseIf Key = Keys.U Then
TextBox1.Text = TextBox1.Text & "U"
ElseIf Key = Keys.V Then
TextBox1.Text = TextBox1.Text & "V"
ElseIf Key = Keys.W Then
TextBox1.Text = TextBox1.Text & "W"
ElseIf Key = Keys.X Then
TextBox1.Text = TextBox1.Text & "X"
ElseIf Key = Keys.Y Then
TextBox1.Text = TextBox1.Text & "Y"
ElseIf Key = Keys.Z Then
TextBox1.Text = TextBox1.Text & "Z"
ElseIf Key = Keys.Space Then
TextBox1.Text = TextBox1.Text & " "
End If
End If
End If

End Sub
Quote:Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
TextBox2.Text = Control.IsKeyLocked(Keys.CapsLock)
TextBox3.Text = ((Control.ModifierKeys And Keys.Shift) = Keys.Shift)
End Sub

Reply


Messages In This Thread
RE: How to hook the keyboard. [VB.NET] [TuT] - by Taitou - 01-03-2011, 03:01 PM
RE: How to hook the keyboard. [VB.NET] [TuT] - by Jamimartin - 09-23-2019, 11:55 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  VB.NET Port Scanner [TUT] Fragma 30 12,667 11-27-2012, 11:26 PM
Last Post: ƃu∀ ıʞƃu∀
  [TUT] MD5 Encrypter & Finder [VB.NET] Fragma 12 6,954 11-25-2012, 10:36 PM
Last Post: ƃu∀ ıʞƃu∀
  [TUT] How to make a simple WebBrowser in VB 2010! [TUT] - [ Pictures] Statics 95 55,594 10-07-2012, 06:56 AM
Last Post: a99
  [TUT]Auto-Update System[TUT] HB Virus 3 2,143 01-07-2012, 02:21 PM
Last Post: Mastermrz
  [TUT]Enable and Disable TaskManger in vb.net [TUT] HB Virus 4 2,845 12-19-2011, 10:10 AM
Last Post: euverve

Forum Jump:


Users browsing this thread: 6 Guest(s)