'添加一个timer 两个command
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Long
Private Sub Command1_Click()
Me.Caption = "是"
End Sub
Private Sub Command2_Click()
Me.Caption = "否"
End Sub
Private Sub Form_Load()
Timer1.Interval = 100
End Sub
Private Sub Timer1_Timer()
If GetAsyncKeyState(vbKeyReturn) Then '检查是否热键被按下,这里是按下回车
Command1_Click
End If
If GetAsyncKeyState(vbKeyEscape) Then 'ESC
Command2_Click
End If
End Sub
回车键没有keycode啊。。。 把回车键换成其他键比如空格的话。。。
在每一个可能获得焦点的控件的keydown事件中,写入:
call yn
yn过程如下:
private sub yn
if keycode=32 then
call cmdyes_click
elseif keycode=27 then
call cmdno_click
end if
end sub
在编程结束的时候不是的