在打开的浏览器中更改URL的批处理文件

时间:2014-04-29 19:06:07

标签: internet-explorer batch-file

我见过这样的事情:

start /d "C:\Program Files\Internet Explorer (x86)\IEXPLORE.EXE" www.google.com

但这只会打开一个新标签。我希望它能改变那些列出的网站。

最终目标是创建一个批处理文件,在两个网页之间切换,并在它们之间有给定的延迟。

2 个答案:

答案 0 :(得分:1)

您应该可以使用SendKeys执行此操作,请参阅here

基本上,您查看Internet Explorer的下拉菜单(即文件,编辑等)并查看您想要执行的操作的快捷键,然后编写一些VBscript来发送这些键击。使用" .VBS"将VBscript保存在一个文件中。扩展然后你可以双击它来运行它。这样的事情应该让你开始......

 set WshShell = WScript.CreateObject("WScript.Shell")
 WshShell.Run "iexplore"
 WScript.Sleep 500
 WshShell.AppActivate "Windows Internet Explorer"
 WshShell.SendKeys "www.google.com"

如果您已经使用自己的START命令启动了IE,那么您可以在此之后发送控制它所需的击键,而您不需要WshShell.Run部分。

答案 1 :(得分:1)

您可以直接在批处理文件中使用SendKeys,如thisthisthis回答中所示;例如:

@if (@CodeSection == @Batch) @then

@echo off

rem Start default IE
start /d "C:\Program Files\Internet Explorer (x86)\IEXPLORE.EXE" www.google.com

:changeLoop
CScript //nologo //E:JScript "%~F0" "keys to change to first webpage"
timeout /T 10
CScript //nologo //E:JScript "%~F0" "keys to change to second webpage"
timeout /T 10
goto changeLoop

@end

WScript.CreateObject("WScript.Shell").SendKeys(WScript.Arguments(0));