VB脚本提交问题

时间:2013-12-04 11:15:45

标签: javascript vbscript

和其他许多人一样,我遇到了自动登录脚本的问题。 我的问题类似于this problem

然而,我的问题是我应该要求的功能。 我不是编码员,但我很热情。

这是我目前的代码:

On Error Resume Next

Const PAGE_LOADED = 4

Set objIE = CreateObject("InternetExplorer.Application")
Call objIE.Navigate("https://autentisering.vll.se/login.html")
objIE.Visible = True

Do Until objIE.ReadyState = PAGE_LOADED : Call WScript.Sleep(100) : Loop

objIE.Document.all.username.Value = "username"
objIE.Document.all.password.Value = "password"

If Err.Number <> 0 Then
  msgbox "Error: " & err.Description
End If

Call objIE.Document.forms(0).submit()

Set objIE = Nothing

这是我试图“破解”的loginscript:

function getHtmlForButton(nameStr, str, bClass,onClickFn) {
  if(nameStr == null || nameStr =="" || str == null || str =="" || onClickFn == null || onClickFn =="") {
    debugMsg("One of the input params for the button is not available");
    return;
  }
  document.writeln('<input type="button" name="',nameStr,'" value="',str,'" class="',bClass,'"  onClick="',onClickFn,'">');
}

function submitAction() {
  if(document.forms[0].err_flag.value == 1) {
    // This case occurs when user's attempt to login failed
    // and he is going to login again. This means we have already
    // extracted redirect url in his first attempt and its stored
    // in redirect_url input element. so just submit the form

    document.forms[0].err_flag.value = 0;
    document.forms[0].buttonClicked.value = 4;
    document.forms[0].submit();
  } else {
    var link = document.location.href;

    //alert("Link is "+link);

    var searchString = "?redirect=";
    var equalIndex = link.indexOf(searchString);
    var redirectUrl = "";

    if(equalIndex > 0) {
      equalIndex += searchString.length;
      redirectUrl=link.substring(equalIndex);
      var index=0;

      //add http only if url does not have
      index=redirectUrl.indexOf("http");

      if(index != 0) {
        redirectUrl = "http://"+ redirectUrl;
      }
    }

    if(redirectUrl.length > 255) {
      redirectUrl = redirectUrl.substring(0,255);
    }

    document.forms[0].redirect_url.value = redirectUrl;

    //alert("redirect url is "+document.forms[0].redirect_url.value);

    document.forms[0].buttonClicked.value = 4;
    document.forms[0].submit();
  }
}

function submitOnEnter(event) {
  var NS4 = (document.layers) ? true : false;
  var code = 0;

  if (NS4)
    code = event.which;
  else
    code = event.keyCode;

  if (code==13) submitAction();
  // 12 corresponds to enter event
}

function checkForMsg() {
  if(document.forms[0].info_flag.value == 1) {
    alert(document.forms[0].info_msg.value);
  }
}

编辑: 我遇到的问题是它不会登录。它输入用户名和密码,但是我得到一个错误,说明“错误:Objektetstöderintegenskapeneller metoden”(它是瑞典语),转换为“错误:对象不支持此属性或方法“(谷歌翻译了一下)

最新编辑: 我将动作线更改为     调用objIE.Document.forms(0).submit() 并删除第一行(On Error Resume Next)。 现在我没有得到任何警告,但它根本不会登录。它会在一瞬间加载和刷新,所以我不知道它是否输入了名称和密码,但由于我没有改变它,它应该这样做。

我做错了什么?

0 个答案:

没有答案