简单的VB问题(键盘控制)加分

来源:百度知道 编辑:UC知道 时间:2024/09/21 23:20:31
如何实现如下功能:
点击一下鼠标左键,则计算机自动按一次delete键?
高手请进!
给出代码好吗?

Option Explicit
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal Scan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Const VK_LBUTTON = &H1
Private Const VK_RBUTTON = &H2

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

Private Sub Timer1_Timer()
If GetAsyncKeyState(VK_LBUTTON) Then
Sleep 500
Call keybd_event(46, 0, 0, 0)
End If

End Sub

全屏测试有效~

Private Sub Form_MouseDown(Button As Integer,Shift As Integer,X As Single,Y As Single)
If Button = 1 Then
KeyAscii=127
End If
End Sub