VBscript写入textarea并提交

时间:2016-02-24 19:29:55

标签: vbscript

我正在尝试写入文本区域并在登录网站后提交。我在尝试附加文本区域时遇到错误,还有其他方法吗?

第一个功能Main正常运行 - IE打开并正确登录网站。然后我转到了textarea所在的slackbot页面。我可以将文本添加到字段中,但无法提交。

守则:

Const dirPath     = "C:\Users\tim.mcgee\Desktop\Offsite Drive"
Const alertedPath = "prevRun.txt"
      alertOn     = 3 * 2 ^ 29 '1.5GB
      resetOn     = alertOn * .95 'Approx 77MB
Const emailTo     = "temcgee7@gmail.com"
Const emailFrom   = "temcgee7@gmail.com"
Const emailSbjct  = "Offsite Drive Full"
Const emailMsg    = "The offsite drive has reached maximum capacity."
Const SMTPServer  = "smtp.gmail.com"
Const SMTPPort    = 465
      emailUsr    = emailFrom 
Const emailPsswd  = "Electricboat1"
Const emailSSL    = False


Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FileExists(alertedPath) Then
  alerted =  CBool(Trim(fso.OpenTextFile(alertedPath).ReadLine))
Else
  alerted = False
End If
dirSize = fso.GetFolder(dirPath).Size

If alerted Then 'Email previously sent
  alerted = dirSize > resetOn
ElseIf dirSize >= alertOn Then
  Call Main
  alerted = True
End If

fso.OpenTextFile(alertedPath, 2, True).WriteLine CInt(alerted)
WScript.Quit 0

Function Main
    Set IE = WScript.CreateObject("InternetExplorer.Application", "IE_")
    IE.Visible = True
    IE.Navigate "https://epic.slack.com/messages/@slackbot/"
    Wait IE
    With IE.Document
        .getElementByID("email").value = "tim.mcgee@epicgames.com"
        .getElementByID("password").value = "Electricboat1"
        .getElementByID("signin_btn").click()
    End With

    WScript.Sleep 5000

    Wait IE
    With IE.Document
        .getElementByID("message-input").appendChild(IE.Document.createtextnode("@channel: Offsite drive is reaching maximum capacity. Please delete old builds."))
        .getElementByID("message-input").submit()
    End With

End Function

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

0 个答案:

没有答案
相关问题