Support Forums
How to hook the keyboard. [VB.NET] [TuT] - Printable Version

+- Support Forums (https://www.supportforums.net)
+-- Forum: Categories (https://www.supportforums.net/forumdisplay.php?fid=87)
+--- Forum: Coding Support Forums (https://www.supportforums.net/forumdisplay.php?fid=18)
+---- Forum: Visual Basic and the .NET Framework (https://www.supportforums.net/forumdisplay.php?fid=19)
+---- Thread: How to hook the keyboard. [VB.NET] [TuT] (/showthread.php?tid=916)

Pages: 1 2 3 4 5 6 7 8 9 10


RE: How to hook the keyboard. [VB.NET] [TuT] - Break - 12-23-2010

Thanks for this it should help me more.


RE: How to hook the keyboard. [VB.NET] [TuT] - SouR'D - 12-25-2010

Very nice source even tho this thread is really
old can always come in handy for someone


RE: How to hook the keyboard. [VB.NET] [TuT] - Taitou - 01-03-2011

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




RE: How to hook the keyboard. [VB.NET] [TuT] - osamutezuka - 03-16-2011

I have a question here.
i want to add hotkey on my program but i just cant make it work.
the hotkey is Control + S
Code:
If Key = Keys.S And Key = Keys.Control Then
            VolumeUp()
End If
It just wont work.
could someone help me??
Sorry for thread Digging


RE: How to hook the keyboard. [VB.NET] [TuT] - Pyratepig - 03-24-2011

Don't forget those who are going to use this, you'll need to make it see when caps is on or off, etc so it will know what to do.


RE: How to hook the keyboard. [VB.NET] [TuT] - Mammoth - 04-18-2011

Nice work i am sure some other will need this.


RE: How to hook the keyboard. [VB.NET] [TuT] - Spectrum - 04-19-2011

Good job Vorfin.
I actually just implemented this into my program, which is a bot.

This made my method (Logging the users TYPED keys) much easier.


RE: How to hook the keyboard. [VB.NET] [TuT] - AjHostings Solutions - 04-21-2011

wow really great idea... i have never have this in my mind.. Tongue


RE: How to hook the keyboard. [VB.NET] [TuT] - Do0ks - 04-28-2011

Nice tutorial, Ill give this a try soon. Thanks mate.


RE: How to hook the keyboard. [VB.NET] [TuT] - Unreal - 04-28-2011

Thanks for this share. Will be using it.