VB如何做到同时按键
展开全部
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Const KEYEVENTF_KEYUP = &H2
Private Sub Command1_Click()
keybd_event vbKeyControl, 0, 0, 0 '按下CTRL键
keybd_event vbKeyMenu, 0, 0, 0 '按下Alt键
keybd_event vbKeyA, 0, 0, 0 '按下A键
keybd_event vbKeyA, 0, KEYEVENTF_KEYUP, 0 '释放A键
keybd_event vbKeyMenu, 0, KEYEVENTF_KEYUP, 0 '释放Alt键
keybd_event vbKeyControl, 0, KEYEVENTF_KEYUP, 0 '释放CTRL键
End Sub
Const KEYEVENTF_KEYUP = &H2
Private Sub Command1_Click()
keybd_event vbKeyControl, 0, 0, 0 '按下CTRL键
keybd_event vbKeyMenu, 0, 0, 0 '按下Alt键
keybd_event vbKeyA, 0, 0, 0 '按下A键
keybd_event vbKeyA, 0, KEYEVENTF_KEYUP, 0 '释放A键
keybd_event vbKeyMenu, 0, KEYEVENTF_KEYUP, 0 '释放Alt键
keybd_event vbKeyControl, 0, KEYEVENTF_KEYUP, 0 '释放CTRL键
End Sub
展开全部
'API声明,复制到最上面一排即可
private declare sub keybd_event lib "user32" alias "keybd_event" (byval key as byte, byval bScan as byte, byval dwflags as long, byval dwExtraInfo As long)
'代码,写在command1_click里面
keybd_event(17, 0, 0, 0)
keybd_event(18, 0, 0, 0)
keybd_event(65, 0, 0, 0)
private declare sub keybd_event lib "user32" alias "keybd_event" (byval key as byte, byval bScan as byte, byval dwflags as long, byval dwExtraInfo As long)
'代码,写在command1_click里面
keybd_event(17, 0, 0, 0)
keybd_event(18, 0, 0, 0)
keybd_event(65, 0, 0, 0)
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Sub Form_Click()
SendKeys "^%a", True
End Sub
SendKeys "^%a", True
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询