Chrome:可以像VBScript中的InternetExplorer.Application一样编写脚本吗?

时间:2014-05-15 16:26:06

标签: google-chrome vbscript

我有一个VBScript使用InternetExplorer.Application登录网站,然后每隔一段时间刷新一次页面,以防止网站因不活动而退出。它位于我们办公室的仪表板屏幕上。有没有办法以类似的方式编写Chrome脚本?它不一定是VBScript,任何语言都可以。我们希望停止使用Internet Explorer。

2 个答案:

答案 0 :(得分:1)

您无法将Google Chrome控制为VBscript中的对象。原因如下:VBScript CreateObject Google Chrome

话虽这么说,你仍然可以在google chrome上操作刷新。只需复制要刷新的页面标题,一旦页面被激活,使用SendKeys命令使其刷新。例如(CTRL + R) - 导致刷新,或者在Sendkeys中(" ^ r")。

一旦你刷新了它,只需将它设置为一个循环并设置你想要的等待时间。

'This is an infinite loop, only disposed of by exiting Wscript.exe or Cscript.exe
Do While(true)
Dim PageTitleToRefresh, IntervalinSeconds, x, objShell, Success

'Page Titles - NOT the page address - (google.com = NO) (Google = YES)
'Page Titles are normally stored at the top of the browser or in the tab name of the browser. 
PageTitleToRefresh = "Google"
IntervalinSeconds = 10

x = IntervalinSeconds * 1000
Set objShell = WScript.CreateObject("WScript.Shell")
    Do Until Success = True
        Success = objShell.AppActivate(PageTitleToRefresh)
        Wscript.Sleep 1000
    Loop
    wscript.echo "Activated, now refreshing"
objShell.SendKeys "^r"

Wscript.Sleep IntervalinSeconds
Loop

答案 1 :(得分:0)

这是我在js文件中编辑的一种方式,但也可以在vbs中实现:

<xsl:template match="text">
    <text>
        <status value="generated"/>
        <div xmlns="http://www.w3.org/1999/xhtml">
            <p>This is the text from the stylesheet </p>                
        </div>
    </text>
</xsl:template>