全局代码:
<DllImport("user32.dll", SetLastError := True)> _
Public Function RegisterHotKey(hWnd As IntPtr, id As Integer, fsModifiers As KeyModifiers, vk As Keys) As Boolean
End Function
<DllImport("user32.dll", SetLastError := True)> _
Public Function UnregisterHotKey(hWnd As IntPtr, id As Integer) As Boolean
End Function
<Flags> _
Public Enum KeyModifiers
None = 0
Alt = 1
Control = 2
Shift = 4
Windows = 8
End Enum
Public Class GlobalKeyDown
Inherits System.Windows.Forms.form
private shared obj As new GlobalKeyDown
private Sub New()
End Sub
Public Shared Function getInstance() As GlobalKeyDown
Return obj
End Function
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
If System.Windows.Forms.Form.ActiveForm Is Nothing Then
Else
Functions.Execute("处理快捷键", m)
MyBase.WndProc(m)
End If
End Sub
End Class