vb 模拟按键的问题

来源:百度知道 编辑:UC知道 时间:2024/06/01 01:32:21
请问如何能达到以下效果
当按F1时则模拟持续单击“D”键
在按F1时则停止模拟持续单击“D”键

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 112 Then
SendKeys "D"
End If
End Sub

Private Sub Form_Load()
Form1.KeyPreview = True
End Sub

按下F1不放就不停按D 放开就停止发送

不告诉你

如果是在程序中的
那么就
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbkeyf1 Then
SendKeys "d"
End If
End Sub

只要你一放开f1建他就停止
http://www.hongen.com/pc/program/progtool/vbkeycod.htm
这个是keycode 的表...要什么键自己查..