vb.net自动打字 利用vbs脚本实现自动打字

如何编程实现在另一程序窗口的文本框自动输入文本并自动跳到另一个文本框或者按钮'使用VBS例vb.net自动打字 , 下载dynwrap.dll,然后拷贝至c:\windows\system32vb.net自动打字 , 运行regsvr32 dynwrap.dll进行注册
Set ws=CreateObject("WSCript.shell")
Set Wrap1 = CreateObject("DynamicWrapper")
Wrap1.Register "USER32.DLL", "FindWindow","I=ss","f=s", "R=l"
Wrap1.Register "USER32.DLL", "SetForegroundWindow", "I=h", "f=s", "R=l"
hWin = Wrap1.FindWindow(vbNullString, CStr("窗口名称"))
if hWin0 then
Clipboard = "MsHta vbscript:ClipBoardData.setData(""Text"",""" "您要输入vb.net自动打字的文本" """)(Close)"
ws.Run(Clipboard)'复制文本
ws.sendkeys "{tab}"'发送tab键移动焦点
ws.sendkeys "^v"'发送粘贴,确保剪切板有内容
end if
vb.net 实现ComboBox输入字符自动补充字符Public Sub AutoComplete(ByVal cmb As ComboBox, ByVal e As System.Windows.Forms.KeyPressEventArgs)
If cmb.DataSource Is Nothing Then
Return
End If
If e.KeyChar = Microsoft.VisualBasic.ChrW(Keys.Enter) Then
Return
End If
Dim strFindStr As String = ""
If e.KeyChar = Microsoft.VisualBasic.ChrW(Keys.Back) Then
If (cmb.SelectionStart = cmb.Text.Length) Then
If cmb.Text.Length0 Then
strFindStr = cmb.Text.Substring(0, cmb.Text.Length - 1)
End If
Else
If cmb.SelectionStart0 Then
strFindStr = cmb.Text.Substring(0, cmb.SelectionStart - 1)
End If
End If
e.Handled = False
Else
If (cmb.SelectionLength = 0) Then
strFindStr = cmb.Text + e.KeyChar
Else
If (cmb.SelectionStart = cmb.Text.Length) Then
strFindStr = e.KeyChar
Else
If cmb.SelectionStart0 Then
strFindStr = cmb.Text.Substring(0, cmb.SelectionStart - 1) + e.KeyChar
Else
strFindStr = e.KeyChar
End If
End If
End If
End If
Dim intIdx As Integer = -1
Dim dv As DataView
If TypeOf (cmb.DataSource) Is DataTable Then
dv = CType(cmb.DataSource, DataTable).DefaultView
If strFindStr"" Then
dv.RowFilter = cmb.DisplayMember" Like '%"strFindStr"%'"
Else
dv.RowFilter = ""
End If
cmb.DataSource = dv
cmb.SelectedIndex = -1
cmb.Text = strFindStr
Else
dv = CType(cmb.DataSource, DataView)
If strFindStr"" Then
dv.RowFilter = cmb.DisplayMember" Like '%"strFindStr"%'"
Else
【vb.net自动打字 利用vbs脚本实现自动打字】dv.RowFilter = ""
End If
cmb.DataSource = dv
cmb.SelectedIndex = -1
cmb.Text = strFindStr
End If
cmb.SelectionStart = strFindStr.Length
e.Handled = True
End Sub
Private Sub comboBox1_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles comboBox1.KeyPress
AutoComplete(sender, e)
End Sub
在vb 。net 做个打字程序 能告诉我正确率的求法 。那个思路 要简单点的 谢谢在TextChanged事件中vb.net自动打字:privatevoidrichTextBox1_TextChanged(objectsender,EventArgse)
{
if(label1.Text==richTextBox1.Text)
richTextBox1.ForeColor=Color.Black;
else
richTextBox1.ForeColor=Color.Red;
}-------------------继续答复:
首先vb.net自动打字,还是建议vb.net自动打字你使用TextChange方法 。KeyPress方法只有在松开键后才触发vb.net自动打字,如果一直按着键比如写a,那这串a颜色不会变的,直到你松手 。
然后上代码,测试可用的,你直接放到KeyPress里也能用:
PrivateSubrichTextBox1_TextChanged(senderAsObject,eAsEventArgs)
ForiAsInteger=0TorichTextBox1.TextLength-1
richTextBox1.SelectionStart=i
richTextBox1.SelectionLength=1
Ifi=label1.Text.LengthThen
richTextBox1.SelectionColor=Color.Blue

推荐阅读