萬盛學電腦網

 萬盛學電腦網 >> 網絡編程 >> 編程語言綜合 >> VB 實現簡單的熱鍵/快捷鍵功能

VB 實現簡單的熱鍵/快捷鍵功能

   代碼如下:

  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個.

copyright © 萬盛學電腦網 all rights reserved