【问题标题】:VBScript CreateObject Google ChromeVBScript CreateObject 谷歌浏览器
【发布时间】:2012-12-22 19:46:49
【问题描述】:

我有这个 VBScript,它工作正常,脚本没有问题,但我想在 Chrome 而不是 IE 中打开它。

我对 VB 脚本非常陌生。 谁能帮帮我。

WScript.Quit Main

Function Main
  Set IE = WScript.CreateObject("InternetExplorer.Application", "IE_")
  IE.Visible = True
  IE.Navigate "http://gmail.com"
  Wait IE
  With IE.Document
    .getElementByID("login_username").value = "myuser"
    .getElementByID("login_password").value = "mypass"
    .getElementByID("frmLogin").submit
  End With
End Function

Sub Wait(IE)
  Do
    WScript.Sleep 500
  Loop While IE.ReadyState < 4 And IE.Busy 
  Do
    WScript.Sleep 500
  Loop While IE.ReadyState < 4 And IE.Busy 
End Sub

Sub IE_OnQuit
  On Error Resume Next
  WScript.StdErr.WriteLine "IE closed before script finished."
  WScript.Quit
End Sub

【问题讨论】:

  • 你也许可以使用Google Chrome Frame,即CreateObject("ChromeTab.ChromeFrame"),但这是一个很长的尝试
  • @oraclecertifiedprofessional:这看起来像是一个答案,而不是评论。
  • @Helen 有效,我没试过
  • @oraclecertifiedprofessional 也没有用。我需要在 JSCRIPT 中编写这段代码。

标签: google-chrome scripting vbscript google-chrome-devtools


【解决方案1】:

【讨论】:

  • 我认为 OP 想要做类似 WScript.CreateObject("Chrome.Application", "Chrome_") 而不是 WScript.CreateObject("InternetExplorer.Application", "IE_") 而不是使用 Chrome 来运行这个 VBScript
  • 啊,谢谢指正。由于“IE在脚本完成之前关闭”,我认为这是相反的。
【解决方案2】:

看看代码。有启动chrome的代码

  set WshShell=WScript.CreateObject("WScript.Shell")
   strAnswer = InputBox("Please enter a name for your new file:")
   WshShell.run "chrome.exe"
   WScript.sleep 100
   WshShell.sendkeys "www.google.com" 
   WshShell.sendkeys "{ENTER}"

【讨论】:

    【解决方案3】:

    很遗憾,您只能打开一些网址,无法像在 Internet Explorer 上那样控制它

    dim objApp : set objApp=createobject("Shell.application")
    objApp.Shellexecute"chrome.exe","www.google.com","","", 1
    

    【讨论】:

    • 您的答案可以通过额外的支持信息得到改进。请edit 添加更多详细信息,例如引用或文档,以便其他人可以确认您的答案是正确的。你可以找到更多关于如何写好答案的信息in the help center
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-01-21
    • 2011-08-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多