HotKey Tutorial
Heres your chance to share your own tutorials with the community. Just post them on here. If your lucky they may even be posted on the main site.
6 posts
Page 1 of 1
Contains:
- 1 timer
- 1 button (not needed)
- 1 label (not needed)![Image]()
- 1 timer
- 1 button (not needed)
- 1 label (not needed)
Code: Select all
Public Class Form1
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vkey As Long) As Integer
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim hotkey1 As Boolean
Dim hotkey2 as Boolean
hotkey2 = GetAsyncKeyState(Keys.controlkey)
hotkey1 = GetAsyncKeyState(Keys.F12)
If hotkey1 And hotkey2 = True Then
Me.visible = false
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer1.Enabled = True
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.Visible = False
End Sub
End Class

Last edited by bjm0008 on Sat Nov 14, 2009 12:34 am, edited 3 times in total.
Retherz123 wrote:cool but how do i add like 2?so its like alt 1do u mean "2" cuz i don't understand you :?
2 = keys.numpad2
@ Ts ; timer requires to much cpu... i would use
Control_mousedown(ByVal e as mouseeventargs)
if e.keycode = keys.enter then
control.dosomething
end if
oh lol i quitted vb like 2 weeks ago and i already forgot everything lol
I somehow doubt a keyboard event would use mouseeventargs. Anyway the reason the above code uses a timer is so the keys can be detected when a different window has focus.
Another way of doing it is with RegisterHotKey. Check out viewtopic.php?f=53&t=1138&p=11978#p11978
Another way of doing it is with RegisterHotKey. Check out viewtopic.php?f=53&t=1138&p=11978#p11978
mandai wrote:I somehow doubt a keyboard event would use mouseeventargs. Anyway the reason the above code uses a timer is so the keys can be detected when a different window has focus.oops yeah i meant keydown lol
Another way of doing it is with RegisterHotKey. Check out viewtopic.php?f=53&t=1138&p=11978#p11978
6 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023