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
'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 Sub Form_Click()
SendKeys "^%a", True
End Sub