Chrome:可以在 VBScript 中编写 InternetExplorer.Application 之类的脚本吗? [英] Chrome: Possible to script like InternetExplorer.Application in VBScript?

查看:89
本文介绍了Chrome:可以在 VBScript 中编写 InternetExplorer.Application 之类的脚本吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have a VBScript that uses InternetExplorer.Application to login to a website, then refresh the page every once in a while to keep the website from logging out due to inactivity. This sits on a dashboard screen mounted in our office. Is there a way to script Chrome in a similar way? It doesn't have to be VBScript, any language will do. We are looking to stop using Internet Explorer.

推荐答案

您无法在 VBscript 中将 Google Chrome 作为对象进行控制.原因如下:VBScript CreateObject Google Chrome

You can't control Google Chrome as an object in VBscript. Here's why: VBScript CreateObject Google Chrome

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

That being said, you CAN still manipulate a refresh on google chrome. Just copy the title of the page you want refreshing, and once the page has been activated, use a SendKeys command to cause it to refresh. e.g.(CTRL+R) - causes refresh, or in Sendkeys ("^r").

刷新后,只需将其设置为循环并设置您想要的等待时间.

Once you've got it refreshing, just set it in a loop and set your wait period for however long you want.

'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

这篇关于Chrome:可以在 VBScript 中编写 InternetExplorer.Application 之类的脚本吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆