用vb也能做熱鍵
放個 Timer 控制項,即使在其他視窗一樣可以偵測
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private Sub Form_Load()
Timer1.Interval = 200
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
If GetAsyncKeyState(vbKeyF1) Then MsgBox "按了F1"
End Sub
底下這種做法 只有在Form中才有作用
Private Sub Form_Load()
Me.KeyPreview = True
End Sub
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyF1 Then MsgBox "F1"
End Sub