VBA暂停和恢复并在后台运行

时间:2014-07-07 04:39:22

标签: vbscript notepad

我对VBS非常陌生,所以希望有人能为我提出一些建议。我正在通过记事本编写VBS脚本,并且我在执行以下操作时遇到了问题:

  1. 用户输入通过输入框请求的信息后暂停然后恢复的脚本
  2. 脚本复制输入的数据然后粘贴到应用程序窗口
  3. 当脚本正在运行时,要等到运行完成后再执行下一个脚本
  4. 用户输入密码后,隐藏窗口并让其在后台运行,允许用户继续执行其他任务
  5. 下面的脚本:

    Set objShell = WScript.CreateObject("WScript.Shell")
    objShell.Exec "app location"
    Do Until Success = True
        Success = objShell.AppActivate("Application")
    Loop
    objshell.Sendkeys "{TAB}{TAB}{TAB}{TAB}{TAB}"
    objShell.SendKeys "*server name*"
    objShell.SendKeys "{enter}"
    
    wscript.sleep 100
    
    strusername=inputbox("Enter your user name","User Name")
    If strusername = "" Then
        Wscript.Quit
    Else
        ObjShell.AppActivate("PuTTY Configuration")
        objshell.SendKeys "+INS", True
        objshell.SendKeys "{enter}"
    
    strpassword=inputbox("Enter your Password","Password")
    If strpassword = "" Then
        Wscript.Quit
    Else
    
        ObjShell.AppActivate("PuTTY Configuration")
        objshell.SendKeys "+INS", True
        objshell.SendKeys "{enter}"
    End if
    
    *Resume the script*
    
    ObjShell.Appactivate("application")
    objShell.SendKeys "server name"
    objShell.SendKeys "{enter}"
    
    ObjShell.Appactivate("application")
    objShell.SendKeys "*I need the password entered earlier to be copied and paste here*"
    objShell.SendKeys "{enter}"
    
    wscript.sleep 1000
    
    ObjShell.Appactivate("*application*")
    objShell.SendKeys "server name"
    objShell.SendKeys "{enter}"
    
    wscript.sleep 6000
    
    and it keeps going until it's finished then does:
    
    ObjShell.Appactivate("*application*")
    objShell.SendKeys "exit"
    objShell.SendKeys "{enter}"
    objShell.SendKeys "exit"
    objShell.SendKeys "{enter}"
    objShell.SendKeys "exit"
    objShell.SendKeys "{enter}"
    

    我也尝试过:

    do while not wscript.StdIn.AtEndofLine
      input=input & wscript.StdIn.ReadLine
     Loop
    do while not wscript.StdIn.AtEndofLine
      input=input & wscript.StdIn.ReadLine
     Loop
    wscript.sleep 1000
    
    ObjShell.Appactivate("*application*")
    objShell.SendKeys "server name"
    

0 个答案:

没有答案