Once again I plead for assistance!
I would like to be able to register multiple hotkeys that are ran from a hidden form. The hotkey for the example program below toggles a second form when ALT+UPKEY is pressed. Right now it performs as it should, but when I uncomment the code that hides the program the hotkeys no longer work. Anyone know where I’m going wrong with this, or possibly know a work around on how to toggle a second form from a hidden program? As always, thank you in advance for your help.
Public Class Form1
Public Declare Function RegisterHotKey Lib "user32" (ByVal hwnd As IntPtr, ByVal id As Integer, ByVal fsModifiers As Integer, ByVal vk As Integer) As Integer
Public Declare Function UnregisterHotKey Lib "user32" (ByVal hwnd As IntPtr, ByVal id As Integer) As Integer
Public Const WM_HOTKEY As Integer = &H312
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
If m.Msg = WM_HOTKEY Then
Form2.Show()
End If
MyBase.WndProc(m)
End Sub
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
Call UnregisterHotKey(Me.Handle, 9)
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Call RegisterHotKey(Me.Handle.ToInt32, 0, &H1, 38) '<-- registers specific hotkeys
'Me.KeyPreview = True
'Me.ShowInTaskbar = False
'Me.ShowIcon = False
'Me.Visible = False
End Sub
End Class