I am trying to use the classes provided in the example from the url below. It encapsulates the same hotkey functionality in a couple of classes.
http://www.codeproject.com/vb/net/mclhotkeynet.asp
- I'm pretty sure I shouldn't be using 123 and 321 as the ID, but I'm not sure what to do there.
- I'm also not sure how to unregister the hotkey when the form closes.
- When I press Windows Key + H, or I press I, both of the Subs are triggered. How do I have each Sub execute seperately?
- With my code, the events are cancelled and not passed on. How do I allow the events to be passed on?
Here is my code which attempts to use these classes. I uploaded the classes I used in GlobalHotkeyListener.zip.
Thanks.
http://www.codeproject.com/vb/net/mclhotkeynet.asp
- I'm pretty sure I shouldn't be using 123 and 321 as the ID, but I'm not sure what to do there.
- I'm also not sure how to unregister the hotkey when the form closes.
- When I press Windows Key + H, or I press I, both of the Subs are triggered. How do I have each Sub execute seperately?
- With my code, the events are cancelled and not passed on. How do I allow the events to be passed on?
Here is my code which attempts to use these classes. I uploaded the classes I used in GlobalHotkeyListener.zip.
VB.NET:
Public Class frmInput
Public WithEvents myActivatorKey As GlobalHotkeyListener
Public WithEvents mySecondKey As GlobalHotkeyListener
Private Sub frmInput_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
'How do I unregister the hotkeys?
End Sub
Private Sub frmInput_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
myActivatorKey = New GlobalHotkeyListener(123, HotkeyModifierFlags.MOD_WIN, Keys.H)
AddHandler myActivatorKey.HotkeyPressed, AddressOf HotkeyPressed
mySecondKey = New GlobalHotkeyListener(321, 0, Keys.I)
AddHandler mySecondKey.HotkeyPressed, AddressOf YouPressedI
End Sub
Public Sub HotkeyPressed(ByVal sender As Object, ByVal e As System.EventArgs)
MessageBox.Show("You pressed Windows Key + H!")
End Sub
Public Sub YouPressedI(ByVal sender As Object, ByVal e As System.EventArgs)
MessageBox.Show("You pressed I!")
End Sub
End Class
Thanks.