怎么让 VB 自动按一窜按键 类似按键精灵

来源:百度知道 编辑:UC知道 时间:2024/09/24 04:25:33
Dim i%
Private Sub Command1_Click()
If Text1.Text = "" Then
Call MsgBox("TEXT内容不能为空!", vbExclamation, "提示")
Else
i = i + 1
If i Mod 2 = 0 Then
Timer1.Enabled = False: Command1.Caption = "开始"
Else
Timer1.Enabled = True: Command1.Caption = "停止"
End If
End If
End Sub

Private Sub Form_Load()
Me.Caption = "SendKeys": Command1.Caption = "开始": Text1 = "" _
: Timer1.Interval = 50: Timer1.Enabled = False
End Sub

Private Sub Text1_Change()
If Len(Text1) > 1 Then Text1 = Left$(Text1, 1)
End Sub

Private Sub Timer1_Timer()
SendKeys "{" & Text1 & "}"
End Sub

=======================================================

上面是我在网上找到的代码 不过每次只能按1个按键
我要一次按52(包括大

你要的是一直持续运行啊,这样的话看我新的代码
Dim i%, ch As String
Private Sub Command1_Click()
If Command1.Caption = "开始" Then
Timer1.Enabled = True: Command1.Caption = "停止"
Else
Timer1.Enabled = False: Command1.Caption = "开始"
ch = "A"
End If
Text1.SetFocus
End Sub

Private Sub Form_Load()
ch = "A"
Me.Caption = "SendKeys"
Command1.Caption = "开始"
Text1 = ""
Timer1.Interval = 50
Timer1.Enabled = False
End Sub

Private Sub Text1_Change()
If Len(Text1) > 1 Then Text1 = Left$(Text1, 1)
End Sub

Private Sub Timer1_Timer()
Select Case ch
Case "A" To "Z"
SendKeys "{" & ch & "}"
If ch = "Z" Then ch = "a"
Case "a" To "