Sinisterly
[VB.Net] Add Hotkeys to your program - Printable Version

+- Sinisterly (https://sinister.ly)
+-- Forum: Coding (https://sinister.ly/Forum-Coding)
+--- Forum: Visual Basic & .NET Framework (https://sinister.ly/Forum-Visual-Basic-NET-Framework)
+--- Thread: [VB.Net] Add Hotkeys to your program (/Thread-VB-Net-Add-Hotkeys-to-your-program)



[VB.Net] Add Hotkeys to your program - 1234hotmaster - 01-30-2011

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:
Code:
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer



Step 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 If

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 Smile


RE: [VB.Net] Add Hotkeys to your program - 1llusion - 01-30-2011

Nice tut!!! Smile
I do like it!!!


RE: [VB.Net] Add Hotkeys to your program - Coder-san - 01-31-2011

Most of the time you don't need a Global Hotkey, so you can just give focus to a certain hidden control, and get keystrokes on that.
At other times this helps. Nice share. Smile


RE: [VB.Net] Add Hotkeys to your program - 1234hotmaster - 09-03-2011

options button?


RE: [VB.Net] Add Hotkeys to your program - asad3man - 09-12-2011

thanx for this , really helped me , but how to make the hotkey from the text , means

i m in textbox , i want put enter as hotkey , so it will press the Button1!


RE: [VB.Net] Add Hotkeys to your program - Kaveman - 09-18-2011

I am try thanks ........