VB定义快捷键.(全局) 50分

来源:百度知道 编辑:UC知道 时间:2024/05/31 17:42:03
最近想用VB做一个程序.突然间想到要用全局快捷键.我的意思是:比如按CTRL+S或其它什么的.就能显示窗体.再按一个如CTRL+H让它隐藏,在WINDOWS桌面上随时能用快捷键乎出.这要怎么做.代码越简单越好.本人很急.希望大家帮助!

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

按ENTER就可以了.

http://stessie.ghoffice.com/article.php?itemid-2648-type-blog.html

学学Windows编程。发送消息~~
难呀,教程全是讲C系列的。