Single Line Input VBS Autotyper

杀马特。学长 韩版系。学妹 提交于 2021-01-21 09:22:10

问题


I am currently trying to make an autotyper in VBS and I cannot figure out how to easily input what is to be typed. Right now, this is what my code has to look like:

Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.AppActivate "notepad"
WScript.sleep 10000
WshShell.SendKeys "H"
WScript.Sleep 100
WshShell.SendKeys "e"
WScript.Sleep 100
WshShell.SendKeys "l"
WScript.Sleep 100
WshShell.SendKeys "l"
WScript.Sleep 100
WshShell.SendKeys "o"

But I really want my code to have all the text that will be auto-typed in just one line instead of me having to repeat the SendKeys for every letter.


回答1:


I made for you a little example that can type letter by letter as a Typewriter.

Hope this what you are looking for !

strText="Hello ! How are you mate ? Hope that everything is OK !" & vbCrlf &_
"This vbscript is made by Hackoo !" 
Call AutoTypeWriter(strText)
'------------------------------------------
Sub AutoTypeWriter(strText)
  intPause = 150
  Set Ws = CreateObject("WScript.Shell")
  'To start Notepad maximized
  Ws.Run "Notepad",3
  WScript.Sleep 1000
  intTextLen = Len(strText)
  For x = 1 to intTextLen
    strTempText = Mid(strText,x,1)
    Ws.Sendkeys strTempText
    WScript.Sleep intPause
  Next
End Sub
'------------------------------------------



来源:https://stackoverflow.com/questions/52069998/single-line-input-vbs-autotyper

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!