正在使用 VBS 提交 Google 表单

Submitting Google Form with VBS

<input type="text" class="quantumWizTextinputPaperinputInput exportInput" jsname="YPqjbf"
autocomplete="off" tabindex="0" aria-label="Untitled question" 
aria-describedby="i.desc.608035577 i.err.608035577" 
name="entry.1790931838" value="" required="" dir="auto" data-initial-dir="auto" 
data-initial-value="" aria-invalid="true">

以上是我想用VBS自动填充的输入框的HTML代码

<span jsslot="" class="appsMaterialWizButtonPaperbuttonContent exportButtonContent"><span class="appsMaterialWizButtonPaperbuttonLabel quantumWizButtonPaperbuttonLabel exportLabel">Submit</span></span>

以上是提交按钮的代码。

On Error Resume Next
Const PAGE_LOADED = 4
Set objIE = CreateObject("InternetExplorer.Application")
objIE.Navigate("https://docs.google.com/forms/d/e/1FAIpQLScOmcmtdsrm3RiX7FD9ur2eLPULL9ZulSzKxjG87BblRky7hQ/viewform")
objIE.Visible = True

WScript.Sleep(3000) 

IE.Document.getElementById("entry.1790931838").Value = "msdasdadm"

这是我自动填写表格的代码,但我似乎没有让它工作。另外,我无法理解如何调用提交按钮并按下它。

这应该让你开始......

On Error Resume Next

Set objIE = CreateObject("InternetExplorer.Application")
objIE.Navigate("https://docs.google.com/forms/d/e/1FAIpQLScOmcmtdsrm3RiX7FD9ur2eLPULL9ZulSzKxjG87BblRky7hQ/viewform")
objIE.Visible = True

WScript.Sleep(3000) 

Dim input, inputs : Set inputs = objIE.document.getElementsByTagName("INPUT")
For Each input In inputs
    If ("text" = input.getAttribute("type")) Then
        input.value = "Just a test"
        Exit For
    End If
Next

Dim div, divs : Set divs = objIE.document.getElementsByTagName("DIV")
For Each div In divs
    If ("button" = div.getAttribute("role") And "M2UYVd" = div.getAttribute("jsname")) Then
        Call div.click()
        Exit For
    End If
Next

提交按钮实际上是一个父 DIV 元素,其中定义了关联的 JS onclick 事件处理程序。但是,请注意 jsname 属性,因为随机名称很可能会在不同形式之间发生变化。

希望对您有所帮助。