代碼如下:
Private Declare Function GetAsyncKeyState Lib "User32" (ByVal Vkey As Long) As Integer
Private Function MyHotKey(vKeyCode) As Boolean
MyHotKey = GetAsyncKeyState(vKeyCode) < 0
End Function
Private Sub Form_Load()
Timer1.Interval = 50
Label1.Caption = "熱鍵是 F1"
End Sub
Private Sub Timer1_Timer()
If MyHotKey(vbKeyF1) Then
MsgBox "你按下了熱鍵!", , "熱鍵提示"
End If
End Sub
控件:標簽1個,時鐘控件1個.