VB 定义快捷键 (全局)

Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer '声明

Function GetKey() As String
    Dim AddKey As String
    KeyResult = GetAsyncKeyState(32) '回车键
    If KeyResult = -32767 Then
        AddKey = "[ENTER]"
        GoTo KeyFound
    End If

    KeyFound
    '显示键的信息
    If AddKey = "" Then
        Exit Function
    Else
        GetKey = AddKey
        '-------------------------
    End If
End Function

Private Sub Timer1_Timer() '显示按键
    Static a As String
    a = GetKey
    If a <> "" Then Label1.Caption = a
End Sub


文章来自: 本站原创
引用通告: 查看所有引用 | 我要引用此文章
Tags: VB
评论: 0 | 引用: 0 | 查看次数: -
发表评论
昵 称:
密 码: 游客发言不需要密码.
内 容:
验证码: 验证码
选 项:
虽然发表评论不用注册,但是为了保护您的发言权,建议您注册帐号.