[VB.Net] Add Hotkeys to your program 01-30-2011, 08:46 PM
#1
hi guys this is a tutorial to add shortcut keys to your programs which work even if the program is not on top.
Step 1:
Start a new project.
Step 2:
Below Form1 add this:
Step 3:
Add a timer and double click it. in the timer's code add this:
Then set the timer's Enabled field to True and interval to 10 ( as low as possible but not 1 because can make double hotkey counted )
Replace MsgBox("Hello you just activated the Hotkey!", MsgBoxStyle.Information) with your code when the key is pressed.
Have a nice day
Step 1:
Start a new project.
Step 2:
Below Form1 add this:
Code:
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As IntegerStep 3:
Add a timer and double click it. in the timer's code add this:
Code:
Dim hotkey1 As String
hotkey1 = GetAsyncKeyState(Keys.F2)
If hotkey1 = True Then
MsgBox("Hello you just activated the Hotkey!", MsgBoxStyle.Information)
End IfThen set the timer's Enabled field to True and interval to 10 ( as low as possible but not 1 because can make double hotkey counted )
Replace MsgBox("Hello you just activated the Hotkey!", MsgBoxStyle.Information) with your code when the key is pressed.
Have a nice day
(This post was last modified: 03-26-2011, 07:10 PM by Skullmeat.)
Pierce the life fibers with your drill.
![[+]](https://sinister.ly/images/modern/collapse_collapsed.png)

![[Image: rytwG00.png]](http://i.imgur.com/rytwG00.png)