一个级难的VB题

来源:百度知道 编辑:UC知道 时间:2024/05/10 08:36:34
打开一个VB程序,最小化等所有状态下按Shift
都可以调用sub shift()?
说全点!!

答案不太麻烦,一个TIMER控件即可

Option Explicit
'按钮事件
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer

Public Sub shift()'你自己的事件
MsgBox "你按下了Shift"
End Sub

Private Sub Form_Load()
Timer1.Interval = 250
End Sub

Private Sub Timer1_Timer()'是否按下shift
If GetAsyncKeyState(vbKeyShift) Then shift
End Sub

不难,有个检测键盘的api ,好像叫做GetKeyboardstatus,不停的在timer控件的处罚时间中调用就行了。

WinApi 底层键盘钩子。