VB如何判断键盘松开
我已经有按下的代码了:OptionExplicitPrivateDeclareFunctionGetAsyncKeyStateLib"user32"(ByValvKeyA...
我已经有按下的代码了:
Option Explicit
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private Sub Form_Load()
Timer1.Interval = 100
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
If GetAsyncKeyState(vbKeyF2) Then
MsgBox "你按了F2键!"
End If
End Sub 展开
Option Explicit
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private Sub Form_Load()
Timer1.Interval = 100
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
If GetAsyncKeyState(vbKeyF2) Then
MsgBox "你按了F2键!"
End If
End Sub 展开
3个回答
展开全部
'----自定义键盘状态常量-----
Private Const WM_KEYDOWN = &H100 '按下键盘按键
Private Const WM_KEYUP = &H101 '弹起键盘按键
Private Const WM_LBUTTONDOWN = &H201 '鼠标左键按下
Private Const WM_LBUTTONUP = &H202 '鼠标左键弹起
Private Const WM_LBUTTONDBLCLK = &H203 '鼠标左键双击
Private Const WM_RBUTTONDOWN = &H204 '鼠标右键按下
Private Const WM_RBUTTONUP = &H205 '鼠标右键弹起
Private Const WM_RBUTTONDBLCLK = &H206 '鼠标右键双击
Private Const WM_MBUTTONDBLCLK = &H209 '鼠标中间键双击
Private Const WM_MBUTTONDOWN = &H207 '鼠标中间键按下
Private Const WM_MBUTTONUP = &H208 '鼠标中间键弹起
Private Const WM_MOUSEMOVE = &H200 '鼠标移动常数
Private Const GAKB_LOCKED = &HFF80 '按键锁定状态。
Private Const GAKB_KEYDOWN = &H80 '按键按下状态。
private sub form_keyup(keycode as integer, shift as integer)
"这就是了
end sub
Private Const WM_KEYDOWN = &H100 '按下键盘按键
Private Const WM_KEYUP = &H101 '弹起键盘按键
Private Const WM_LBUTTONDOWN = &H201 '鼠标左键按下
Private Const WM_LBUTTONUP = &H202 '鼠标左键弹起
Private Const WM_LBUTTONDBLCLK = &H203 '鼠标左键双击
Private Const WM_RBUTTONDOWN = &H204 '鼠标右键按下
Private Const WM_RBUTTONUP = &H205 '鼠标右键弹起
Private Const WM_RBUTTONDBLCLK = &H206 '鼠标右键双击
Private Const WM_MBUTTONDBLCLK = &H209 '鼠标中间键双击
Private Const WM_MBUTTONDOWN = &H207 '鼠标中间键按下
Private Const WM_MBUTTONUP = &H208 '鼠标中间键弹起
Private Const WM_MOUSEMOVE = &H200 '鼠标移动常数
Private Const GAKB_LOCKED = &HFF80 '按键锁定状态。
Private Const GAKB_KEYDOWN = &H80 '按键按下状态。
private sub form_keyup(keycode as integer, shift as integer)
"这就是了
end sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询