vb中如何用快捷键调出窗口

若一个窗体用Hide将其隐藏,使其在后台运行,怎样利用快捷键调出该窗体?求代码……... 若一个窗体用Hide将其隐藏,使其在后台运行,怎样利用快捷键调出该窗体?求代码…… 展开
 我来答
richway2
推荐于2016-08-13 · 超过50用户采纳过TA的回答
知道小有建树答主
回答量:150
采纳率:0%
帮助的人:98.8万
展开全部
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
'Keyboards
Const KEY_BACK = &H08
Const KEY_TAB = &H09
Const KEY_RETURN = &H0D
Const KEY_SHIFT = &H10
Const KEY_CTRL = &H11
Const KEY_ALT = &H12
Const KEY_PAUSE = &H13
Const KEY_CAPSLOCK = &H14
Const KEY_ESC = &H1B
Const KEY_PAGEUP = &H21
Const KEY_PAGEDOWN = &H22
Const KEY_END = &H23
Const KEY_HOME = &H24
Const KEY_LEFT = &H25
Const KEY_UP = &H26
Const KEY_RIGHT = &H27
Const KEY_DOWN = &H28
Const KEY_SELECT = &H29
Const KEY_PRINT = &H2A
Const KEY_PRINTSCREEN = &H2C
Const KEY_INSERT = &H2D
Const KEY_DELETE = &H2E

'小键盘的数字
Const KEY_SMALL0 = &H60
Const KEY_SMALL1 = &H61
Const KEY_SMALL2 = &H62
Const KEY_SMALL3 = &H63
Const KEY_SMALL4 = &H64
Const KEY_SMALL5 = &H65
Const KEY_SMALL6 = &H66
Const KEY_SMALL7 = &H67
Const KEY_SMALL8 = &H68
Const KEY_SMALL9 = &H69

Dim IsTrigger As Boolean

Private Sub Form_Load()
GetAsyncKeyState(Asc("快捷键")) '必须分多个KeyState一起
End Sub
新建一个tmrShow的时钟控件
Private Sub tmrShow_Timer()
If GetAsyncKeyState(Asc("快捷键")) <> 0 And IsTrigger = False Then '如果有打不出来的快捷键用KEY_快捷键表示,前面已经定义完成
Me.Visible = Not Me.Visible
IsTrigger = True
ElseIf IsTrigger = True
IsTrigger = False
End If
End Sub

例子:Ctrl+5做快捷键
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
'Keyboards
Const KEY_BACK = &H08
Const KEY_TAB = &H09
Const KEY_RETURN = &H0D
Const KEY_SHIFT = &H10
Const KEY_CTRL = &H11
Const KEY_ALT = &H12
Const KEY_PAUSE = &H13
Const KEY_CAPSLOCK = &H14
Const KEY_ESC = &H1B
Const KEY_PAGEUP = &H21
Const KEY_PAGEDOWN = &H22
Const KEY_END = &H23
Const KEY_HOME = &H24
Const KEY_LEFT = &H25
Const KEY_UP = &H26
Const KEY_RIGHT = &H27
Const KEY_DOWN = &H28
Const KEY_SELECT = &H29
Const KEY_PRINT = &H2A
Const KEY_PRINTSCREEN = &H2C
Const KEY_INSERT = &H2D
Const KEY_DELETE = &H2E

'小键盘的数字
Const KEY_SMALL0 = &H60
Const KEY_SMALL1 = &H61
Const KEY_SMALL2 = &H62
Const KEY_SMALL3 = &H63
Const KEY_SMALL4 = &H64
Const KEY_SMALL5 = &H65
Const KEY_SMALL6 = &H66
Const KEY_SMALL7 = &H67
Const KEY_SMALL8 = &H68
Const KEY_SMALL9 = &H69

Dim IsTrigger As Boolean

Private Sub Form_Load()
GetAsyncKeyState(Asc("5")) And GetAsyncKeyState(KEY_CTRL) '必须分多个KeyState一起
End Sub
新建一个tmrShow的时钟控件
Private Sub tmrShow_Timer()
If GetAsyncKeyState(Asc("5")) <> 0 And GetAsyncKeyState(KEY_CTRL) <> 0 And IsTrigger = False Then '如果有打不出来的快捷键用KEY_快捷键表示,前面已经定义完成
Me.Visible = Not Me.Visible
IsTrigger = True
ElseIf IsTrigger = True
IsTrigger = False
End If
End Sub

参考资料: 键盘输入均从魔塔的大键盘脚本做改动

hawking_xu
2010-03-18 · TA获得超过215个赞
知道小有建树答主
回答量:211
采纳率:0%
帮助的人:156万
展开全部
设置全局热键,要很多代码
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式