我想编一个程序,内容是这样的
当我按下H健,文本中可以输入 A,延迟200ms,输入B,延迟200ms,输入C
而H,A,B,C,以及2个延迟都是可以手动输入改变的
请问我该怎么编写?
方法应该有很多,比如API函数,Sendkeys函数,还有驱动级别的
当我按下H健,文本中可以输入 A,延迟200ms,输入B,延迟200ms,输入C
而H,A,B,C,以及2个延迟都是可以手动输入改变的
请问我该怎么编写?
方法应该有很多,比如API函数,Sendkeys函数,还有驱动级别的
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = Asc("h") Then
KeyAscii = 0
Text1.Text = Text1.Text & "A"
Sleep 200
Text1.Text = Text1.Text & "B"
Sleep 200
Text1.Text = Text1.Text & "C"
End If
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 72 Or KeyAscii = 104 Then
Text1.Text = ""
Dalay "A", 2000
Dalay "B", 2000
Dalay "C", 2000
End If
End Sub
Private Sub Dalay(ByVal S As String, ByVal t As Integer)
Sleep t
SendKeys S
DoEvents
End Sub
五楼的思路对了,不过最后处理得有点问题,我如果按“H“,结果是ABCh
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 72 Or KeyAscii = 104 Then
Text1.Text = ""
Dalay "A", 2000
Dalay "B", 2000
Dalay "C", 2000
KeyAscii=0
End If
End SubPrivate Sub Dalay(ByVal S As String, ByVal t As Integer)
Sleep t
SendKeys S
DoEvents
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 72 Or KeyAscii = 104 Then
Text1.Text = ""
SendKeys "A"
Sleep 2000
DoEventsSendKeys "B"
Sleep 2000
DoEventsSendKeys "C"
Sleep 2000
KeyAscii = 0End If
End Sub
我给修改成这样了,总算成功了,只是不明白,为什么总是会有h?怎么还需要清空才行?