我正在尝试使用VBS编写脚本但是我遇到了使代码正常工作的问题。我必须能够使用谷歌浏览器运行此脚本。我需要这个脚本来填写网站上的用户名和密码并“登录”。我使用Google Chrome中的开发者工具检查了该页面,但没有具体说明这是页面上用户名文本框和密码文本框的元素ID。
<input id="user_name_input" type="text" name="username" size="20" value="">
<input id="password_input" type="password" name="password" size="20" value="">
我已经做了一段时间了,我不能让它在没有轰炸的情况下运行。我在网上发现这个脚本会正确地打开页面,但我找不到任何可以让我过去的东西。
Dim iURL
Dim objShell
iURL = "Website URL"
set objShell = CreateObject("WScript.Shell")
objShell.run(iURL)
我知道用于设置ID值的Internet Explorer脚本是
IE.Document.All.Item("user_name_input").Value = "The@Email"
IE.Document.All.Item("password_input").Value = "Password"
但是当我需要它在Chrome中运行时,这不起作用。请帮忙。
答案 0 :(得分:0)
Google Chrome不使用vbscript。只有Internet Explorer可以,并且处于兼容模式。
适合您情况的错误语言。使用JScript。
答案 1 :(得分:0)
请勿复制此文字;它将自动打开chrome,只需使用.vbs保存
function readFromRegistry (strRegistryKey, strDefault)
Dim WSHShell, value
On Error Resume Next
Set WSHShell = CreateObject ("WScript.Shell")
value = WSHShell.RegRead (strRegistryKey)
if err.number <> 0 then
readFromRegistry= strDefault
else
readFromRegistry=value
end if
set WSHShell = nothing
end function
function OpenWithChrome(strURL)
Dim strChrome
Dim WShellChrome
strChrome = readFromRegistry ( "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe\Path", "")
if (strChrome = "") then
strChrome = "chrome.exe"
else
strChrome = strChrome & "\chrome.exe"
end if
Set WShellChrome = CreateObject("WScript.Shell")
strChrome = """" & strChrome & """" & " " & strURL
WShellChrome.Run strChrome, 1, false
end function
OpenWithChrome "https://www.google.co.in/"